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.

Document generated on: 2015-05-22 (revision: 43237)


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 Module mysql.connector
10.1.1 Method mysql.connector.connect()
10.1.2 Property mysql.connector.apilevel
10.1.3 Property mysql.connector.paramstyle
10.1.4 Property mysql.connector.threadsafety
10.1.5 Property mysql.connector.__version__
10.1.6 Property mysql.connector.__version_info__
10.2 Class connection.MySQLConnection
10.2.1 Constructor connection.MySQLConnection(**kwargs)
10.2.2 Method MySQLConnection.close()
10.2.3 Method MySQLConnection.commit()
10.2.4 Method MySQLConnection.config(**kwargs)
10.2.5 Method MySQLConnection.connect()
10.2.6 Method MySQLConnection.cursor()
10.2.7 Method MySQLConnection.cmd_change_user(username='', password='', database='', charset=33)
10.2.8 Method MySQLConnection.cmd_debug()
10.2.9 Method MySQLConnection.cmd_init_db(database)
10.2.10 Method MySQLConnection.cmd_ping()
10.2.11 Method MySQLConnection.cmd_process_info()
10.2.12 Method MySQLConnection.cmd_process_kill(mysql_pid)
10.2.13 Method MySQLConnection.cmd_query(statement)
10.2.14 Method MySQLConnection.cmd_query_iter(statement)
10.2.15 Method MySQLConnection.cmd_quit()
10.2.16 Method MySQLConnection.cmd_refresh(options)
10.2.17 Method MySQLConnection.cmd_reset_connection()
10.2.18 Method MySQLConnection.cmd_shutdown()
10.2.19 Method MySQLConnection.cmd_statistics()
10.2.20 Method MySQLConnection.disconnect()
10.2.21 Method MySQLConnection.get_row()
10.2.22 Method MySQLConnection.get_rows(count=None)
10.2.23 Method MySQLConnection.get_server_info()
10.2.24 Method MySQLConnection.get_server_version()
10.2.25 Method MySQLConnection.is_connected()
10.2.26 Method MySQLConnection.isset_client_flag(flag)
10.2.27 Method MySQLConnection.ping(attempts=1, delay=0)
10.2.28 Method MySQLConnection.reconnect(attempts=1, delay=0)
10.2.29 Method MySQLConnection.reset_session()
10.2.30 Method MySQLConnection.rollback()
10.2.31 Method MySQLConnection.set_charset_collation(charset=None, collation=None)
10.2.32 Method MySQLConnection.set_client_flags(flags)
10.2.33 Method MySQLConnection.shutdown()
10.2.34 Method MySQLConnection.start_transaction()
10.2.35 Property MySQLConnection.autocommit
10.2.36 Property MySQLConnection.charset_name
10.2.37 Property MySQLConnection.collation_name
10.2.38 Property MySQLConnection.connection_id
10.2.39 Property MySQLConnection.database
10.2.40 Property MySQLConnection.get_warnings
10.2.41 Property MySQLConnection.in_transaction
10.2.42 Property MySQLConnection.raise_on_warnings
10.2.43 Property MySQLConnection.server_host
10.2.44 Property MySQLConnection.server_port
10.2.45 Property MySQLConnection.sql_mode
10.2.46 Property MySQLConnection.time_zone
10.2.47 Property MySQLConnection.unix_socket
10.2.48 Property MySQLConnection.user
10.3 Class pooling.MySQLConnectionPool
10.3.1 Constructor pooling.MySQLConnectionPool
10.3.2 Method MySQLConnectionPool.add_connection()
10.3.3 Method MySQLConnectionPool.get_connection()
10.3.4 Method MySQLConnectionPool.set_config()
10.3.5 Property MySQLConnectionPool.pool_name
10.4 Class pooling.PooledMySQLConnection
10.4.1 Constructor pooling.PooledMySQLConnection
10.4.2 Method PooledMySQLConnection.close()
10.4.3 Method PooledMySQLConnection.config()
10.4.4 Property PooledMySQLConnection.pool_name
10.5 Class cursor.MySQLCursor
10.5.1 Constructor cursor.MySQLCursor
10.5.2 Method MySQLCursor.callproc()
10.5.3 Method MySQLCursor.close()
10.5.4 Method MySQLCursor.execute()
10.5.5 Method MySQLCursor.executemany()
10.5.6 Method MySQLCursor.fetchall()
10.5.7 Method MySQLCursor.fetchmany()
10.5.8 Method MySQLCursor.fetchone()
10.5.9 Method MySQLCursor.fetchwarnings()
10.5.10 Method MySQLCursor.stored_results()
10.5.11 Property MySQLCursor.column_names
10.5.12 Property MySQLCursor.description
10.5.13 Property MySQLCursor.lastrowid
10.5.14 Property MySQLCursor.statement
10.5.15 Property MySQLCursor.with_rows
10.6 cursor.MySQLCursor Subclasses
10.6.1 Class cursor.MySQLCursorBuffered
10.6.2 Class cursor.MySQLCursorRaw
10.6.3 Class cursor.MySQLCursorBufferedRaw
10.6.4 Class cursor.MySQLCursorDict
10.6.5 Class cursor.MySQLCursorBufferedDict
10.6.6 Class cursor.MySQLCursorNamedTuple
10.6.7 Class cursor.MySQLCursorBufferedNamedTuple
10.6.8 Class cursor.MySQLCursorPrepared
10.7 Class constants.ClientFlag
10.8 Class constants.FieldType
10.9 Class constants.SQLMode
10.10 Class constants.CharacterSet
10.11 Class constants.RefreshOption
10.12 Errors and Exceptions
10.12.1 Module errorcode
10.12.2 Exception errors.Error
10.12.3 Exception errors.DataError
10.12.4 Exception errors.DatabaseError
10.12.5 Exception errors.IntegrityError
10.12.6 Exception errors.InterfaceError
10.12.7 Exception errors.InternalError
10.12.8 Exception errors.NotSupportedError
10.12.9 Exception errors.OperationalError
10.12.10 Exception errors.PoolError
10.12.11 Exception errors.ProgrammingError
10.12.12 Exception errors.Warning
10.12.13 Function errors.custom_error_exception(error=None, exception=None)
11 Connector/Python C Extension API Reference
11.1 Module _mysql_connector
11.2 Class _mysql_connector.MySQL()
11.3 Method _mysql_connector.MySQL.affected_rows()
11.4 Method _mysql_connector.MySQL.autocommit()
11.5 Method _mysql_connector.MySQL.buffered()
11.6 Method _mysql_connector.MySQL.change_user()
11.7 Method _mysql_connector.MySQL.character_set_name()
11.8 Method _mysql_connector.MySQL.close()
11.9 Method _mysql_connector.MySQL.commit()
11.10 Method _mysql_connector.MySQL.connect()
11.11 Method _mysql_connector.MySQL.connected()
11.12 Method _mysql_connector.MySQL.consume_result()
11.13 Method _mysql_connector.MySQL.convert_to_mysql()
11.14 Method _mysql_connector.MySQL.escape_string()
11.15 Method _mysql_connector.MySQL.fetch_fields()
11.16 Method _mysql_connector.MySQL.fetch_row()
11.17 Method _mysql_connector.MySQL.field_count()
11.18 Method _mysql_connector.MySQL.free_result()
11.19 Method _mysql_connector.MySQL.get_character_set_info()
11.20 Method _mysql_connector.MySQL.get_client_info()
11.21 Method _mysql_connector.MySQL.get_client_version()
11.22 Method _mysql_connector.MySQL.get_host_info()
11.23 Method _mysql_connector.MySQL.get_proto_info()
11.24 Method _mysql_connector.MySQL.get_server_info()
11.25 Method _mysql_connector.MySQL.get_server_version()
11.26 Method _mysql_connector.MySQL.get_ssl_cipher()
11.27 Method _mysql_connector.MySQL.hex_string()
11.28 Method _mysql_connector.MySQL.insert_id()
11.29 Method _mysql_connector.MySQL.more_results()
11.30 Method _mysql_connector.MySQL.next_result()
11.31 Method _mysql_connector.MySQL.num_fields()
11.32 Method _mysql_connector.MySQL.num_rows()
11.33 Method _mysql_connector.MySQL.ping()
11.34 Method _mysql_connector.MySQL.query()
11.35 Method _mysql_connector.MySQL.raw()
11.36 Method _mysql_connector.MySQL.refresh()
11.37 Method _mysql_connector.MySQL.rollback()
11.38 Method _mysql_connector.MySQL.select_db()
11.39 Method _mysql_connector.MySQL.set_character_set()
11.40 Method _mysql_connector.MySQL.shutdown()
11.41 Method _mysql_connector.MySQL.stat()
11.42 Method _mysql_connector.MySQL.thread_id()
11.43 Method _mysql_connector.MySQL.use_unicode()
11.44 Method _mysql_connector.MySQL.warning_count()
11.45 Property _mysql_connector.MySQL.have_result_set
A Licenses for Third-Party Components
A.1 Django 1.5.1 License