首页 技术 正文
技术 2022年11月23日
0 收藏 742 点赞 3,332 浏览 2256 个字

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.

上一篇: ubutu安装搜狗
下一篇: phpcms数据库操作
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848