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:

MySQL Connector/Python v1.1.3 beta

Connector/Python v1.1.3 is available for testing since last week. It is a “beta” release, so it would be great if we even get more feedback. Check out the Change History if you want to keep up with what is being added and changed.

Notable changes for v1.1.3 include a fix for encoding using \x5c or backslashes in multi-byte characters. We also made the code more PEP-8 compliant, which we think is quiet important.

Some useful links:

Snippet: Show column information using MySQL Connector/Python


You have a query executed by MySQL Connector/Python and would like to show column information nicely on the console.


Every cursor object has a description property. This can be used to show information about the columns in a result set.

columns = []
maxnamesize = 0
for coldesc in cur.description:
    coldesc = list(coldesc)
    coldesc[2:6] = []
    namesize = len(coldesc[0])
    if namesize > maxnamesize:
        maxnamesize = namesize

fmt = "{{nr:3}} {{name:{0}}} {{type:12}} {{null}}".format(
colnr = 1
for column in columns:
    (colname, fieldtype, nullok, colflags) = column
        null='NOT NULL' if nullok else 'NULL',
    colnr += 1


There are two parts in the code snippet. The for-loop goes over the columns and saves the information we need. We also figure out the longest column name. (Yes, we could put the column name at the end but then it would not be much fun.)

On line 4 we use the cursor description property. It returns a list of tuples which contains information about the column in the result set. The information is defined by PEP-249, though only the first 2 items, name and column type, are mandatory. The last field is kind of a MySQL extension returning the flags of the column. On line 20 we fetch the name of the column data type using the FieldType class.

If you’d like to get information about the column flags, import and use FieldFlag:


Below is example of output, for a table created using CREATE TABLE t1 (name VARCHAR(20), day_of_birth DATE).

  1 name          VAR_STRING   NOT NULL
  2 day_of_birth  DATE         NOT NULL

MySQL Fabric support in Connector/Python

MySQL Fabric was officially introduced during Tomas his keynote at MySQL Connect 2013. MySQL Fabric will help you managing lots of MySQL server supporting both high-availability and sharding. Just like Connector/J, MySQL Connector/Python v1.1.1 Alpha has support for MySQL Fabric on MySQL Labs. Note that the MySQL Fabric as well as support for it in Connector/Python is Alpha.

When you download MySQL Connector/Python from MySQL Labs, you will also see a ZIP archive containing the MySQL Utilities documentation as PDF. You will find everything in there to get started. It’s a big document, but look for ‘Fabric’.

It’s probably a good idea to read up on MySQL Fabric from following excellent blog posts authored by the guys who made it happen:

Here are the usual references for MySQL Connector/Python: