MySQL Connector/Python Developer Guide  /  The Connector/Python C Extension  /  The _mysql_connector C Extension Module

8.2 The _mysql_connector C Extension Module

To use the C Extension directly, import the _mysql_connector module rather than mysql.connector, then use the _mysql_connector.MySQL() class to obtain a MySQL instance. For example:

import _mysql_connector

ccnx = _mysql_connector.MySQL()
ccnx.connect(user='scott', password='password',
             host='127.0.0.1', database='employees')

ccnx.query("SHOW VARIABLES LIKE 'version%'")
row = ccnx.fetch_row()
while row:
  print(row)
  row = ccnx.fetch_row()
ccnx.free_result()

ccnx.close()

For more information, see Chapter 11, Connector/Python C Extension API Reference.