Currently, MySQL Connector/Python is only available through Launchpad. Here’s a small how-to for installing it using the Bazaar bzr client tool. All you need is a machine with Python installed (v2.3 or higher, but not v3.x), and.. well, that’s it!

bzr checkout lp:~mysql/myconnpy/main myconnpy
cd myconnpy
python setup.py install

Please check it out. It’s not feature complete yet, and probably can use some code optimizations here and there. I’m looking forward to bug reports! Also, only works with MySQL 4.1 and above.

Here is a little script that shows how it works, save it in file test_myconn.py:

import mysql.connector

if __name__ == "__main__":
  db = mysql.connector.Connect(host="localhost",
    user="root",password="",database="test")
  cursor = db.cursor()
  cursor.execute("SHOW ENGINES")

  for row in cursor.fetchall():
    print row

  cursor.close()
  db.close()

Execute it like this and you should see the available storage engines:

shell> python test_myconn.py
[u'InnoDB', u'YES', u'Supports transactions, row-level locking, and foreign keys', u'YES', u'YES', u'YES']
[u'MRG_MYISAM', u'YES', u'Collection of identical MyISAM tables', u'NO', u'NO', u'NO']
[u'BLACKHOLE', u'YES', u'/dev/null storage engine (anything you write to it disappears)', u'NO', u'NO', u'NO']
[u'CSV', u'YES', u'CSV storage engine', u'NO', u'NO', u'NO']
[u'MEMORY', u'YES', u'Hash based, stored in memory, useful for temporary tables', u'NO', u'NO', u'NO']
[u'FEDERATED', u'NO', u'Federated MySQL storage engine', None, None, None]
[u'ARCHIVE', u'YES', u'Archive storage engine', u'NO', u'NO', u'NO']
[u'MyISAM', u'DEFAULT', u'Default engine as of MySQL 3.23 with great performance', u'NO', u'NO', u'NO']