Python 3 and MySQL

I am using ActiveState Python 3 on Windows and wanted to connect to my MySQL database. I heard that mysqldb was the module to use. I can’t find mysqldb for Python 3.

Is there a repository available where the binaries exist for mysqldb? How can I connect to MySQL in Python 3 on Windows?

improve this question
Thanks to casevh for the link to the unofficial binaries, but I was too impatient and it appears that the masses are still using python2 … so I installed python 2.7 and installed MySQLdb from – panofish Feb 10 ’11 at 18:27

11 Answers

up vote
85down voteaccepted

There are currently a few options for using Python 3 with mysql:

  • Officially supported by Oracle
  • Pure python
  • A little slow
  • Not compatible with MySQLdb

  • Pure python
  • Faster than mysql-connector
  • Almost completely compatible with MySQLdb, after calling pymysql.install_as_MySQLdb()

  • fork of pymysql with optional C speedups

  • Django’s recommended library.
  • Friendly fork of the original MySQLdb, hopes to merge back some day
  • The fastest implementation, as it is C based.
  • The most compatible with MySQLdb, as it is a fork

benchmarks here: