Class cursor.MySQLCursorBuffered

该类从Class cursor.MySQLCursorBuffered继承,如果需要,可以在执行完SQL语句后自动缓冲结果集合。
import mysql.connector
cnx = mysql.connector.connect()
# Only this particular cursor will buffer results
cnx.cursor(buffered=True)
# All cursors will be buffering by default
cnx2 = mysql.connector.connect(buffered=True)

Class cursor.MySQLCursorPrepared
该类继承cursor.MySQLCursor,使用二进制协议执行prepare statement
使用方法:
import mysql.connector
from mysql.connector.cursor import MySQLCursorPrepared
cnx = mysql.connector.connect(database='employees')
cursor = cnx.cursor(cursor_class=MySQLCursorPrepared)
此时cursor为MySQLCursorPrepared对象。

举例:
cursor = cnx.cursor(cursor_class=MySQLCursorPrepared)
stmt = "SELECT fullname FROM employees WHERE id = ?" # (1)
cursor.execute(stmt, (5,)) # (2)
# ... fetch data ...
cursor.execute(stmt, (10,)) # (3)
# ... fetch data ...

Class constants.ClientFlag
This class provides constants defining MySQL client flags that can be used when the connection is established to configure the session.

>>> import mysql.connector
>>> mysql.connector.ClientFlag.FOUND_ROWS
2

Class constants.FieldType
该类不能被实例化,支持所有MySQL的数据类型。
from __future__ import print_function
import mysql.connector
from mysql.connector import FieldType
cnx = mysql.connector.connect(user='scott', database='test')
cursor = cnx.cursor()
cursor.execute(
"SELECT DATE(NOW()) AS `c1`, TIME(NOW()) AS `c2`, "
"NOW() AS `c3`, 'a string' AS `c4`, 42 AS `c5`")
rows = cursor.fetchall()
for desc in cursor.description:
colname = desc[0]
coltype = desc[1]
print("Column {} has type {}".format(
colname, FieldType.get_info(coltype)))
cursor.close()
cnx.close()

Class constants.SQLMode
提供所有已知的SQL服务器模式。具体参见
http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html

Class constants.CharacterSet
提供MYSQL的字符集和默认的collations。参见Method MySQLConnection.set_charset_collation

Class constants.RefreshOption
该类提供多种flush的操作。
RefreshOption.GRANT
Refresh the grant tables, like FLUSH PRIVILEGES.

RefreshOption.LOG
Flush the logs, like FLUSH LOGS.

RefreshOption.TABLES
Flush the table cache, like FLUSH TABLES.

RefreshOption.HOSTS
Flush the host cache, like FLUSH HOSTS.

RefreshOption.STATUS
Reset status variables, like FLUSH STATUS.

RefreshOption.THREADS
Flush the thread cache.

RefreshOption.SLAVE
On a slave replication server, reset the master server information and restart the slave, like RESET SLAVE.

RefreshOption.MASTER

On a master replication server, remove the binary log files listed in the binary log index and truncate the index file, like RESET MASTER.

MySQL Python教程(4)的更多相关文章

  1. MySQL Python教程(1)

    首先对于数据库的基本操作要有一定基础,其次了解Python的基础语法. 建议先阅读MysqL中文教程http://doc.mysql.cn/mysql5/refman-5.1-zh.html-chap ...

  2. MySQL Python教程(2)

    mysql官网关于python的API是最经典的学习材料,相信对于所有函数浏览一遍以后,Mysql数据库用起来一定得心应手. 首先看一下Connector/Python API包含哪些类和模块. Mo ...

  3. MySQL Python教程(3)

    Class cursor.MySQLCursor 具体方法和属性如下:Constructor cursor.MySQLCursorMethod MySQLCursor.callproc(procnam ...

  4. Python教程:操作数据库,MySql的安装详解

    各位志同道合的同仁请点击上方关注 本教程是基于Python语言的深入学习.本次主要介绍MySql数据库软件的安装.不限制语言语法,对MySql数据库安装有疑惑的各位同仁都可以查看一下. 如想查看学习P ...

  5. 数据库 之MySQL 简单教程

      So Easy系列之MySQL数据库教程 1.   数据库概述 1.1.  数据库概述 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生于距今六十多年前,随着信息技术和 ...

  6. Python教程:连接数据库,对数据进行增删改查操作

    各位志同道合的同仁可以点击上方关注↑↑↑↑↑↑ 本教程致力于程序员快速掌握Python语言编程. 本文章内容是基于上次课程Python教程:操作数据库,MySql的安装详解 和python基础知识之上 ...

  7. Windows下安装MySQL详细教程

    Windows下安装MySQL详细教程 1.安装包下载  2.安装教程 (1)配置环境变量 (2)生成data文件 (3)安装MySQL (4)启动服务 (5)登录MySQL (6)查询用户密码 (7 ...

  8. MySQL 【教程二】

    MySQL 创建数据表 创建MySQL数据表需要以下信息: 表名 表字段名 定义每个表字段 语法 以下为创建MySQL数据表的SQL通用语法: # CREATE TABLE table_name (c ...

  9. python入门灵魂5问--python学习路线,python教程,python学哪些,python怎么学,python学到什么程度

    一.python入门简介 对于刚接触python编程或者想学习python自动化的人来说,基本都会有以下python入门灵魂5问--python学习路线,python教程,python学哪些,pyth ...

随机推荐

  1. Linux Shell 从入门到删除根目录跑路指南

    1.变量为空导致误删文件base_path=/usr/sbintmp_file=`cmd_invalid`# rm -rf $base_path/$tmp_file这种情况下如果 cmd 执行出错或者 ...

  2. 【项目】Http请求在NSMutableURLRequest添加HttpBody的字典params属性

    在请求头中加入字典集合的Body,首先把字典转换成json,然后json转换成NSData,然后加入到HTTPBody中,我有已下写法 // 参数paramsNSDictionary * params ...

  3. 支持向量机(SVM)入门

    一.简介 支持向量机,一种监督学习方法,因其英文名为support vector machine,故一般简称SVM. 通俗来讲,它是一种二类分类模型,其基本模型定义为特征空间上的间隔最大的线性分类器, ...

  4. wpf读取mysql字段类型为text的问题

    在读取数据库中的字段时,可能会根据环境的不同导致一些字段的读取方式不尽相同,在sql数据库中读取字段值用的最多的算是dataTable.Rows[行][列],但是到了mysql中就会有一些差别,在fl ...

  5. 《深入理解bootstrap》读书笔记:第三章 CSS布局

    一. 概述一下理念 bootstrap基于H5开发.提倡移动先行(媒询声明是必须的),对浏览器支持面不是很广. 响应式图片:max-width:100% height:auto; 可以加上:.img- ...

  6. DrawCall

    [精]draw call 理解和优化 http://bubuko.com/infodetail-387899.html DrawCall 优化 . http://www.cnblogs.com/sof ...

  7. Linux下MySQL忘记密码

    系统:CentOS6.6 64位 参考文档(截图请看原网址): Linux下MySQL忘记root密码怎么办_百度经验 http://jingyan.baidu.com/article/1709ad8 ...

  8. How to get http response.

    public class HttpWebResponseUtility { public static string CreateGetHttpResponse(string url) { var r ...

  9. EF--Codefirst 加密数据库连接字符串

    http://www.tuicool.com/articles/QvYbEn 一.EF,CodeFirst加密SQL连接符 public LifeHelpContext() : base(" ...

  10. vs2013 支持C#6.0 Install-Package Microsoft.Net.Compilers

    vs2013 支持C#6.0  Install-Package Microsoft.Net.Compilers