Work related posts

MySQL Connector/Python v1.2.1 RC

Monday 31 March 2014 proved to be a big day for MySQL with 5 announcements of products getting new releases: the next milestone release MySQL Server 5.7.4, MySQL Workbench 6.1 going GA and Connector/J 5.1.30 and MySQL Utilities 1.4.2 RC which include MySQL Fabric. That’s 4, the fifth being Connector/Python.

Connector/Python v1.2.1 has been released as Release Candidate. Check out the Change History if you want to keep up with what is being added and changed.

Here is an overview of new features and important bug fixes for Connector/Python v1.2:

  • Added support for MySQL Fabric
  • Support for MySQL’s Authentication Plugins: mysql_clear_password and sha256_password are now supported over an SSL connection.
  • Failing over connections (note: not MySQL Fabric HA)

I am sure the a above will spark some interesting follow-up blog posts (at last, some activity, some might say!).

Some useful links:

Snippet: Fetching results after calling stored procedures using MySQL Connector/Python


Using MySQL Connector/Python, you are calling a stored procedure which is also selecting data and you would like to fetch the rows of the result.


For this example we create a stored procedure which is executing SHOW SLAVE STATUS.

cnx = mysql.connector.connect(user='scott', password='tiger',
cur = cnx.cursor()
cur.execute("DROP PROCEDURE IF EXISTS slave_status")

for result_cursor in cur.stored_results():
 for row in result_cursor:

The result from the above would be:

shell> python
Waiting for master to send event


The stored_results() method of cursor object is retiring an iterator object which will go over the results proceeded after calling the stored procedure. Each result is actually a MySQLCursorBuffered object.

You could also use the with_rows cursor property to check if the cursor actually could return rows or not (for example, for SELECT statements). An example is provided in the documentation.

MySQL Connector/Python v1.1.6 GA

This week we released MySQL Connector/Python v1.1.6 has been released with a fix for the Django backend. If you  wonder (or not?) where Connector/Python v1.1.5, it got released a few weeks ago. Yes, PyPi has been updated! Don’t forget to use –allow-external using newest pip.

Some useful links:

Installing MySQL Connector/Python using pip v1.5

The latest pip versions will fail on you when the packages it needs to install are not hosted on PyPI. When you try to install MySQL Connector/Python the usually way, you get following message is:

shell> pip install mysql-connector-python
  Could not find any downloads that satisfy the requirement 
  Some externally hosted files were ignored 
    (use --allow-external mysql-connector-python to allow).

I have updated the download URL to include the MD5 checksum, and MySQL Connector/Python should now install using pip using following command:

shell> pip install --allow-external mysql-connector-python \

Yes, you have to repeat the mysql-connector-python name.

MySQL Connector/Python v1.1.4 GA

It has been a busy week for the Pythonic MySQL Team at Oracle: MySQL Utilities 1.3.6 and a brand new Utilities 1.4.1 Alpha has been release which includes Fabric. Yes, and of course, the one binding them all: Connector/Python v1.1.4 has been released as GA (General Available). Check out the Change History if you want to keep up with what is being added and changed.

New features found in v1.1:

  • Important: Connector/Python will not work with Python v2.4 or v2.5. Yes, I consider this a feature.
  • Connector/Python comes with it’s own database backend for Django v1.4 and v1.5. It supports Python v3 and also support microsecond precision when using MySQL 5.6 and later.
  • MySQL Prepared Statements are now supported.
  • Connection Pooling is now available baked into Connector/Python.
  • Start transactions using the MySQLConnection start_transaction() method and find out whether the session has a transaction on going using the in_transaction property.

Some useful links: