没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
MySQL Connector/Python Developer Guide
Abstract
This manual describes how to install and configure MySQL Connector/Python, a self-contained Python driver for
communicating with MySQL servers, and how to use it to develop database applications.
For notes detailing the changes in each release of Connector/Python, see MySQL Connector/Python Release Notes.
For legal information, see the Legal Notices.
For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss
your issues with other MySQL users.
For additional documentation on MySQL products, including translations of the documentation into other languages,
and downloadable versions in variety of formats, including HTML and PDF formats, see the MySQL Documentation
Library.
Document generated on: 2015-11-28 (revision: 45687)
iii
Table of Contents
Preface and Legal Notices ................................................................................................................ vii
1 Introduction to MySQL Connector/Python ......................................................................................... 1
2 Guidelines for Python Developers .................................................................................................... 3
3 Connector/Python Versions ............................................................................................................. 5
4 Connector/Python Installation .......................................................................................................... 7
4.1 Obtaining Connector/Python ................................................................................................. 7
4.2 Installing Connector/Python from a Binary Distribution ............................................................ 8
4.3 Installing Connector/Python from a Source Distribution ........................................................... 9
4.4 Verifying Your Connector/Python Installation ........................................................................ 11
5 Connector/Python Coding Examples .............................................................................................. 13
5.1 Connecting to MySQL Using Connector/Python ................................................................... 13
5.2 Creating Tables Using Connector/Python ............................................................................ 15
5.3 Inserting Data Using Connector/Python ............................................................................... 17
5.4 Querying Data Using Connector/Python .............................................................................. 18
6 Connector/Python Tutorials ........................................................................................................... 21
6.1 Tutorial: Raise Employee's Salary Using a Buffered Cursor .................................................. 21
7 Connector/Python Connection Establishment .................................................................................. 23
7.1 Connector/Python Connection Arguments ............................................................................ 23
7.2 Connector/Python Option-File Support ................................................................................. 28
8 The Connector/Python C Extension ............................................................................................... 31
8.1 Application Development with the Connector/Python C Extension ......................................... 31
8.2 The _mysql_connector C Extension Module ........................................................................ 32
9 Connector/Python Other Topics ..................................................................................................... 33
9.1 Connector/Python Connection Pooling ................................................................................. 33
9.2 Connector/Python Fabric Support ........................................................................................ 35
9.3 Connector/Python Django Backend ..................................................................................... 35
10 Connector/Python API Reference ................................................................................................. 37
10.1 mysql.connector Module ................................................................................................... 39
10.1.1 mysql.connector.connect() Method .......................................................................... 39
10.1.2 mysql.connector.apilevel Property ........................................................................... 39
10.1.3 mysql.connector.paramstyle Property ...................................................................... 40
10.1.4 mysql.connector.threadsafety Property .................................................................... 40
10.1.5 mysql.connector.__version__ Property .................................................................... 40
10.1.6 mysql.connector.__version_info__ Property ............................................................. 40
10.2 connection.MySQLConnection Class ................................................................................. 40
10.2.1 connection.MySQLConnection() Constructor ............................................................ 40
10.2.2 MySQLConnection.close() Method .......................................................................... 41
10.2.3 MySQLConnection.commit() Method ....................................................................... 41
10.2.4 MySQLConnection.config() Method ......................................................................... 41
10.2.5 MySQLConnection.connect() Method ...................................................................... 42
10.2.6 MySQLConnection.cursor() Method ........................................................................ 42
10.2.7 MySQLConnection.cmd_change_user() Method ...................................................... 43
10.2.8 MySQLConnection.cmd_debug() Method ................................................................ 43
10.2.9 MySQLConnection.cmd_init_db() Method ................................................................ 43
10.2.10 MySQLConnection.cmd_ping() Method ................................................................. 43
10.2.11 MySQLConnection.cmd_process_info() Method ..................................................... 43
10.2.12 MySQLConnection.cmd_process_kill() Method ...................................................... 44
10.2.13 MySQLConnection.cmd_query() Method ............................................................... 44
10.2.14 MySQLConnection.cmd_query_iter() Method ......................................................... 44
10.2.15 MySQLConnection.cmd_quit() Method .................................................................. 45
10.2.16 MySQLConnection.cmd_refresh() Method ............................................................. 45
MySQL Connector/Python Developer Guide
iv
10.2.17 MySQLConnection.cmd_reset_connection() Method ............................................... 45
10.2.18 MySQLConnection.cmd_shutdown() Method .......................................................... 45
10.2.19 MySQLConnection.cmd_statistics() Method ........................................................... 45
10.2.20 MySQLConnection.disconnect() Method ................................................................ 46
10.2.21 MySQLConnection.get_row() Method .................................................................... 46
10.2.22 MySQLConnection.get_rows() Method .................................................................. 46
10.2.23 MySQLConnection.get_server_info() Method ......................................................... 46
10.2.24 MySQLConnection.get_server_version() Method .................................................... 46
10.2.25 MySQLConnection.is_connected() Method ............................................................ 46
10.2.26 MySQLConnection.isset_client_flag() Method ........................................................ 47
10.2.27 MySQLConnection.ping() Method ......................................................................... 47
10.2.28 MySQLConnection.reconnect() Method ................................................................. 47
10.2.29 MySQLConnection.reset_session() Method ........................................................... 47
10.2.30 MySQLConnection.rollback() Method .................................................................... 48
10.2.31 MySQLConnection.set_charset_collation() Method ................................................. 48
10.2.32 MySQLConnection.set_client_flags() Method ......................................................... 48
10.2.33 MySQLConnection.shutdown() Method .................................................................. 49
10.2.34 MySQLConnection.start_transaction() Method ....................................................... 49
10.2.35 MySQLConnection.autocommit Property ............................................................... 50
10.2.36 MySQLConnection.charset_name Property ............................................................ 50
10.2.37 MySQLConnection.collation_name Property .......................................................... 50
10.2.38 MySQLConnection.connection_id Property ............................................................ 50
10.2.39 MySQLConnection.database Property ................................................................... 50
10.2.40 MySQLConnection.get_warnings Property ............................................................. 50
10.2.41 MySQLConnection.in_transaction Property ............................................................ 51
10.2.42 MySQLConnection.raise_on_warnings Property ..................................................... 51
10.2.43 MySQLConnection.server_host Property ............................................................... 52
10.2.44 MySQLConnection.server_port Property ................................................................ 52
10.2.45 MySQLConnection.sql_mode Property .................................................................. 52
10.2.46 MySQLConnection.time_zone Property ................................................................. 52
10.2.47 MySQLConnection.unix_socket Property ............................................................... 53
10.2.48 MySQLConnection.user Property .......................................................................... 53
10.3 pooling.MySQLConnectionPool Class ................................................................................ 53
10.3.1 pooling.MySQLConnectionPool Constructor ............................................................ 53
10.3.2 MySQLConnectionPool.add_connection() Method .................................................... 53
10.3.3 MySQLConnectionPool.get_connection() Method ..................................................... 54
10.3.4 MySQLConnectionPool.set_config() Method ............................................................ 54
10.3.5 MySQLConnectionPool.pool_name Property ........................................................... 55
10.4 pooling.PooledMySQLConnection Class ............................................................................ 55
10.4.1 pooling.PooledMySQLConnection Constructor ......................................................... 55
10.4.2 PooledMySQLConnection.close() Method ................................................................ 55
10.4.3 PooledMySQLConnection.config() Method .............................................................. 56
10.4.4 PooledMySQLConnection.pool_name Property ........................................................ 56
10.5 cursor.MySQLCursor Class ............................................................................................... 56
10.5.1 cursor.MySQLCursor Constructor ........................................................................... 57
10.5.2 MySQLCursor.callproc() Method ............................................................................. 57
10.5.3 MySQLCursor.close() Method ................................................................................. 58
10.5.4 MySQLCursor.execute() Method ............................................................................. 58
10.5.5 MySQLCursor.executemany() Method ..................................................................... 59
10.5.6 MySQLCursor.fetchall() Method .............................................................................. 60
10.5.7 MySQLCursor.fetchmany() Method ......................................................................... 60
10.5.8 MySQLCursor.fetchone() Method ............................................................................ 60
10.5.9 MySQLCursor.fetchwarnings() Method .................................................................... 61
10.5.10 MySQLCursor.stored_results() Method .................................................................. 61
MySQL Connector/Python Developer Guide
v
10.5.11 MySQLCursor.column_names Property ................................................................. 62
10.5.12 MySQLCursor.description Property ....................................................................... 62
10.5.13 MySQLCursor.lastrowid Property .......................................................................... 63
10.5.14 MySQLCursor.rowcount Property .......................................................................... 63
10.5.15 MySQLCursor.statement Property ......................................................................... 63
10.5.16 MySQLCursor.with_rows Property ......................................................................... 64
10.6 Subclasses cursor.MySQLCursor ...................................................................................... 64
10.6.1 cursor.MySQLCursorBuffered Class ........................................................................ 64
10.6.2 cursor.MySQLCursorRaw Class ............................................................................. 65
10.6.3 cursor.MySQLCursorBufferedRaw Class ................................................................. 65
10.6.4 cursor.MySQLCursorDict Class .............................................................................. 66
10.6.5 cursor.MySQLCursorBufferedDict Class .................................................................. 66
10.6.6 cursor.MySQLCursorNamedTuple Class ................................................................. 67
10.6.7 cursor.MySQLCursorBufferedNamedTuple Class ..................................................... 67
10.6.8 cursor.MySQLCursorPrepared Class ....................................................................... 67
10.7 constants.ClientFlag Class ................................................................................................ 68
10.8 constants.FieldType Class ................................................................................................ 69
10.9 constants.SQLMode Class ................................................................................................ 69
10.10 constants.CharacterSet Class ......................................................................................... 69
10.11 constants.RefreshOption Class ........................................................................................ 69
10.12 Errors and Exceptions .................................................................................................... 70
10.12.1 errorcode Module ................................................................................................ 71
10.12.2 errors.Error Exception .......................................................................................... 71
10.12.3 errors.DataError Exception ................................................................................... 73
10.12.4 errors.DatabaseError Exception ............................................................................ 73
10.12.5 errors.IntegrityError Exception .............................................................................. 73
10.12.6 errors.InterfaceError Exception ............................................................................. 73
10.12.7 errors.InternalError Exception ............................................................................... 73
10.12.8 errors.NotSupportedError Exception ...................................................................... 74
10.12.9 errors.OperationalError Exception ......................................................................... 74
10.12.10 errors.PoolError Exception .................................................................................. 74
10.12.11 errors.ProgrammingError Exception ..................................................................... 74
10.12.12 errors.Warning Exception ................................................................................... 74
10.12.13 errors.custom_error_exception() Function ............................................................ 74
11 Connector/Python C Extension API Reference ............................................................................. 77
11.1 _mysql_connector Module ................................................................................................ 78
11.2 _mysql_connector.MySQL() Class ..................................................................................... 78
11.3 _mysql_connector.MySQL.affected_rows() Method ............................................................. 78
11.4 _mysql_connector.MySQL.autocommit() Method ................................................................ 79
11.5 _mysql_connector.MySQL.buffered() Method ..................................................................... 79
11.6 _mysql_connector.MySQL.change_user() Method .............................................................. 79
11.7 _mysql_connector.MySQL.character_set_name() Method ................................................... 79
11.8 _mysql_connector.MySQL.close() Method .......................................................................... 79
11.9 _mysql_connector.MySQL.commit() Method ....................................................................... 80
11.10 _mysql_connector.MySQL.connect() Method .................................................................... 80
11.11 _mysql_connector.MySQL.connected() Method ................................................................ 80
11.12 _mysql_connector.MySQL.consume_result() Method ........................................................ 80
11.13 _mysql_connector.MySQL.convert_to_mysql() Method ...................................................... 81
11.14 _mysql_connector.MySQL.escape_string() Method ........................................................... 81
11.15 _mysql_connector.MySQL.fetch_fields() Method ............................................................... 81
11.16 _mysql_connector.MySQL.fetch_row() Method ................................................................. 81
11.17 _mysql_connector.MySQL.field_count() Method ............................................................... 82
11.18 _mysql_connector.MySQL.free_result() Method ................................................................ 82
11.19 _mysql_connector.MySQL.get_character_set_info() Method .............................................. 82
剩余101页未读,继续阅读
资源评论
lishuhuakai
- 粉丝: 732
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- unidac29 for delphi 12.1
- Cauchy奇异积分的数值计算程序
- 基于Python实现的股票量化交易策略源代码+视频讲解+案例代码,含RSI策略、BOP指标策略、KDJ策略、MACD指标策略等
- EDA编码.zip
- 文本分类任务训练神经网络来学习词汇表中每个词的词向量
- MyBatis进阶技巧:探索动态SQL的无限可能.md
- HM2300C-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- HM2300B-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 员工解除劳动合同申请表.pdf
- 物模块模型代码,前往设计物模块所属
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功