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. Beta版本——第五次冲刺博客

    我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...

  2. 《JavaScript权威指南》学习笔记 第四天 数组

    昨天学习了js的对象,了解了js的原型链.在js里面万事万物皆对象,只不过一些原始类型要经过包装对象的包装才能暂时变为对象.数组的本质是什么呢?数组其实就是一组数,也就是链表.每个数只是这个链表上的一 ...

  3. global--命名空间的使用(一些零散的js方法)

    var GLOBAL = {}; GLOBAL.namespace = function (str) { var arr = str.split('.'), o = GLOBAL; for (var ...

  4. iOS - 如何自动播放H5中的音频

    场景:iOS端设备,App页面跳转到H5产品介绍,背景音乐无法播放.(为什么不能自动播放,因该是iPhone人性化设定吧~) 加载H5用UIWebView空间: 代码: CGRect rect = s ...

  5. IOS VFL屏幕自适应

    -(void)fun1{ //注意使用VFL,不用设置视图的frame UIView *view = [[UIView alloc] init]; view.backgroundColor = [UI ...

  6. cpg数据库处理_找到未提取的pdf

    cpg数据库处理_找到未提取的pdf,存放于文件夹Chinese_undeal_pdfs move_unextracted_pdfs.py # -*- coding: utf-8 -*- " ...

  7. sql优化之not in

    sql : select ID from awhere XX <> 0 and ID not in (select ID from b) 4万多条记录,执行了316秒,无法接受.   优化 ...

  8. Spring MVC学习笔记——给Controller和视图传值

    一.给Controller传值,值将显示在控制台 1.第一种:使用@RequestParam,改HelloController.java //RequestMapping表示用哪一个url来对应 @R ...

  9. Java数据结构——优先级队列

    //================================================= // File Name : PriorityQueue_demo //------------ ...

  10. NAT穿透解决方案介绍

    最近公司要实现在各种网络环境下面的多屏互动(机顶盒.android phone.iphone及PC端)的需求:由于IP地址资源有限的原因,目前我们使用的各种终端设备都位于局域网后面也就是多台设备共享同 ...