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.

Licensing information.  This product may include third-party software, used under license. If you are using a Commercial release of MySQL Connector/Python, see this document for licensing information, including licensing information relating to third-party software that may be included in this Commercial release. If you are using a Community release of MySQL Connector/Python, see this document for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Document generated on: 2016-06-23 (revision: 48022)


Table of Contents

Preface and Legal Notices
1 Introduction to MySQL Connector/Python
2 Guidelines for Python Developers
3 Connector/Python Versions
4 Connector/Python Installation
4.1 Obtaining Connector/Python
4.2 Installing Connector/Python from a Binary Distribution
4.3 Installing Connector/Python from a Source Distribution
4.4 Verifying Your Connector/Python Installation
5 Connector/Python Coding Examples
5.1 Connecting to MySQL Using Connector/Python
5.2 Creating Tables Using Connector/Python
5.3 Inserting Data Using Connector/Python
5.4 Querying Data Using Connector/Python
6 Connector/Python Tutorials
6.1 Tutorial: Raise Employee's Salary Using a Buffered Cursor
7 Connector/Python Connection Establishment
7.1 Connector/Python Connection Arguments
7.2 Connector/Python Option-File Support
8 The Connector/Python C Extension
8.1 Application Development with the Connector/Python C Extension
8.2 The _mysql_connector C Extension Module
9 Connector/Python Other Topics
9.1 Connector/Python Connection Pooling
9.2 Connector/Python Fabric Support
9.3 Connector/Python Django Backend
10 Connector/Python API Reference
10.1 mysql.connector Module
10.1.1 mysql.connector.connect() Method
10.1.2 mysql.connector.apilevel Property
10.1.3 mysql.connector.paramstyle Property
10.1.4 mysql.connector.threadsafety Property
10.1.5 mysql.connector.__version__ Property
10.1.6 mysql.connector.__version_info__ Property
10.2 connection.MySQLConnection Class
10.2.1 connection.MySQLConnection() Constructor
10.2.2 MySQLConnection.close() Method
10.2.3 MySQLConnection.commit() Method
10.2.4 MySQLConnection.config() Method
10.2.5 MySQLConnection.connect() Method
10.2.6 MySQLConnection.cursor() Method
10.2.7 MySQLConnection.cmd_change_user() Method
10.2.8 MySQLConnection.cmd_debug() Method
10.2.9 MySQLConnection.cmd_init_db() Method
10.2.10 MySQLConnection.cmd_ping() Method
10.2.11 MySQLConnection.cmd_process_info() Method
10.2.12 MySQLConnection.cmd_process_kill() Method
10.2.13 MySQLConnection.cmd_query() Method
10.2.14 MySQLConnection.cmd_query_iter() Method
10.2.15 MySQLConnection.cmd_quit() Method
10.2.16 MySQLConnection.cmd_refresh() Method
10.2.17 MySQLConnection.cmd_reset_connection() Method
10.2.18 MySQLConnection.cmd_shutdown() Method
10.2.19 MySQLConnection.cmd_statistics() Method
10.2.20 MySQLConnection.disconnect() Method
10.2.21 MySQLConnection.get_row() Method
10.2.22 MySQLConnection.get_rows() Method
10.2.23 MySQLConnection.get_server_info() Method
10.2.24 MySQLConnection.get_server_version() Method
10.2.25 MySQLConnection.is_connected() Method
10.2.26 MySQLConnection.isset_client_flag() Method
10.2.27 MySQLConnection.ping() Method
10.2.28 MySQLConnection.reconnect() Method
10.2.29 MySQLConnection.reset_session() Method
10.2.30 MySQLConnection.rollback() Method
10.2.31 MySQLConnection.set_charset_collation() Method
10.2.32 MySQLConnection.set_client_flags() Method
10.2.33 MySQLConnection.shutdown() Method
10.2.34 MySQLConnection.start_transaction() Method
10.2.35 MySQLConnection.autocommit Property
10.2.36 MySQLConnection.can_consume_results Property
10.2.37 MySQLConnection.charset Property
10.2.38 MySQLConnection.collation Property
10.2.39 MySQLConnection.connection_id Property
10.2.40 MySQLConnection.database Property
10.2.41 MySQLConnection.get_warnings Property
10.2.42 MySQLConnection.in_transaction Property
10.2.43 MySQLConnection.raise_on_warnings Property
10.2.44 MySQLConnection.server_host Property
10.2.45 MySQLConnection.server_port Property
10.2.46 MySQLConnection.sql_mode Property
10.2.47 MySQLConnection.time_zone Property
10.2.48 MySQLConnection.unix_socket Property
10.2.49 MySQLConnection.user Property
10.3 pooling.MySQLConnectionPool Class
10.3.1 pooling.MySQLConnectionPool Constructor
10.3.2 MySQLConnectionPool.add_connection() Method
10.3.3 MySQLConnectionPool.get_connection() Method
10.3.4 MySQLConnectionPool.set_config() Method
10.3.5 MySQLConnectionPool.pool_name Property
10.4 pooling.PooledMySQLConnection Class
10.4.1 pooling.PooledMySQLConnection Constructor
10.4.2 PooledMySQLConnection.close() Method
10.4.3 PooledMySQLConnection.config() Method
10.4.4 PooledMySQLConnection.pool_name Property
10.5 cursor.MySQLCursor Class
10.5.1 cursor.MySQLCursor Constructor
10.5.2 MySQLCursor.callproc() Method
10.5.3 MySQLCursor.close() Method
10.5.4 MySQLCursor.execute() Method
10.5.5 MySQLCursor.executemany() Method
10.5.6 MySQLCursor.fetchall() Method
10.5.7 MySQLCursor.fetchmany() Method
10.5.8 MySQLCursor.fetchone() Method
10.5.9 MySQLCursor.fetchwarnings() Method
10.5.10 MySQLCursor.stored_results() Method
10.5.11 MySQLCursor.column_names Property
10.5.12 MySQLCursor.description Property
10.5.13 MySQLCursor.lastrowid Property
10.5.14 MySQLCursor.rowcount Property
10.5.15 MySQLCursor.statement Property
10.5.16 MySQLCursor.with_rows Property
10.6 Subclasses cursor.MySQLCursor
10.6.1 cursor.MySQLCursorBuffered Class
10.6.2 cursor.MySQLCursorRaw Class
10.6.3 cursor.MySQLCursorBufferedRaw Class
10.6.4 cursor.MySQLCursorDict Class
10.6.5 cursor.MySQLCursorBufferedDict Class
10.6.6 cursor.MySQLCursorNamedTuple Class
10.6.7 cursor.MySQLCursorBufferedNamedTuple Class
10.6.8 cursor.MySQLCursorPrepared Class
10.7 constants.ClientFlag Class
10.8 constants.FieldType Class
10.9 constants.SQLMode Class
10.10 constants.CharacterSet Class
10.11 constants.RefreshOption Class
10.12 Errors and Exceptions
10.12.1 errorcode Module
10.12.2 errors.Error Exception
10.12.3 errors.DataError Exception
10.12.4 errors.DatabaseError Exception
10.12.5 errors.IntegrityError Exception
10.12.6 errors.InterfaceError Exception
10.12.7 errors.InternalError Exception
10.12.8 errors.NotSupportedError Exception
10.12.9 errors.OperationalError Exception
10.12.10 errors.PoolError Exception
10.12.11 errors.ProgrammingError Exception
10.12.12 errors.Warning Exception
10.12.13 errors.custom_error_exception() Function
11 Connector/Python C Extension API Reference
11.1 _mysql_connector Module
11.2 _mysql_connector.MySQL() Class
11.3 _mysql_connector.MySQL.affected_rows() Method
11.4 _mysql_connector.MySQL.autocommit() Method
11.5 _mysql_connector.MySQL.buffered() Method
11.6 _mysql_connector.MySQL.change_user() Method
11.7 _mysql_connector.MySQL.character_set_name() Method
11.8 _mysql_connector.MySQL.close() Method
11.9 _mysql_connector.MySQL.commit() Method
11.10 _mysql_connector.MySQL.connect() Method
11.11 _mysql_connector.MySQL.connected() Method
11.12 _mysql_connector.MySQL.consume_result() Method
11.13 _mysql_connector.MySQL.convert_to_mysql() Method
11.14 _mysql_connector.MySQL.escape_string() Method
11.15 _mysql_connector.MySQL.fetch_fields() Method
11.16 _mysql_connector.MySQL.fetch_row() Method
11.17 _mysql_connector.MySQL.field_count() Method
11.18 _mysql_connector.MySQL.free_result() Method
11.19 _mysql_connector.MySQL.get_character_set_info() Method
11.20 _mysql_connector.MySQL.get_client_info() Method
11.21 _mysql_connector.MySQL.get_client_version() Method
11.22 _mysql_connector.MySQL.get_host_info() Method
11.23 _mysql_connector.MySQL.get_proto_info() Method
11.24 _mysql_connector.MySQL.get_server_info() Method
11.25 _mysql_connector.MySQL.get_server_version() Method
11.26 _mysql_connector.MySQL.get_ssl_cipher() Method
11.27 _mysql_connector.MySQL.hex_string() Method
11.28 _mysql_connector.MySQL.insert_id() Method
11.29 _mysql_connector.MySQL.more_results() Method
11.30 _mysql_connector.MySQL.next_result() Method
11.31 _mysql_connector.MySQL.num_fields() Method
11.32 _mysql_connector.MySQL.num_rows() Method
11.33 _mysql_connector.MySQL.ping() Method
11.34 _mysql_connector.MySQL.query() Method
11.35 _mysql_connector.MySQL.raw() Method
11.36 _mysql_connector.MySQL.refresh() Method
11.37 _mysql_connector.MySQL.rollback() Method
11.38 _mysql_connector.MySQL.select_db() Method
11.39 _mysql_connector.MySQL.set_character_set() Method
11.40 _mysql_connector.MySQL.shutdown() Method
11.41 _mysql_connector.MySQL.stat() Method
11.42 _mysql_connector.MySQL.thread_id() Method
11.43 _mysql_connector.MySQL.use_unicode() Method
11.44 _mysql_connector.MySQL.warning_count() Method
11.45 _mysql_connector.MySQL.have_result_set Property
Index