MySQL-db lib for Python 3.x?

43,877

Solution 1

As for future plans of MySQLdb, you might want to ask the author (Andy Dustman).
His blog is here: http://mysql-python.blogspot.com/

Solution 2

It appears the MySQLdb is pretty much a dead project. However, PyMySQL is a dbapi compliant, pure-python implementation of a mysql client, and it has python 3 support.

EDIT: There's also MySQL Connector/Python. Same idea.

Solution 3

I was looking for it too, but also found nothing, so I ported MySQL-python-1.2.3 to py3k you can read it here http://sourceforge.net/p/mysql-python/discussion/70460/thread/61e3a3c9/

Solution 4

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

https://pypi.python.org/pypi/mysql-connector-python

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

https://pypi.python.org/pypi/pymysql

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

https://pypi.python.org/pypi/cymysql

  • fork of pymysql with optional C speedups

https://pypi.python.org/pypi/mysqlclient

  • 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
  • Debian and Ubuntu use it to provide both python-mysqldb andpython3-mysqldb packages.

benchmarks here: https://github.com/methane/mysql-driver-benchmarks

Solution 5

Here is a working repository for Python 3: https://github.com/davispuh/MySQL-for-Python-3

Share:
43,877
thr
Author by

thr

Updated on September 29, 2020

Comments

  • thr
    thr over 3 years

    So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.

  • Nick
    Nick about 11 years
    For those finding this post 4.5 years later like me, according to your post, mysql-db support for Python 3 is coming soon, based on that blog. Woohoo.
  • Prof. Falken
    Prof. Falken over 10 years
    Actually, we could not get MySQL Connector/Python to work with Python 3.3 and SQLAlchemy. PyMySQL seems to work great though.
  • Prof. Falken
    Prof. Falken over 10 years
    Anecdote: had trouble with Python 3.3 + SQLAlchemy + Python Connector.
  • CptSupermrkt
    CptSupermrkt over 10 years
    And for those finding this post 5 years later like me, it looks like that blog hasn't been updated since the above comment, and that Python 3 support for MySQLdb is still non-existent. :(
  • davispuh
    davispuh over 10 years
    by the way, it's been on GitHub for few years github.com/davispuh/MySQL-for-Python-3
  • peiman F.
    peiman F. almost 9 years
    And for those finding this post 7-8 years later like me, there is a official connector for mysql here : dev.mysql.com/downloads/connector/python ...history is growing up so slowly...
  • Bob Stein
    Bob Stein about 8 years
    pip install mysql-connector-python works with Python 2.7.11 and 3.5.1. Concerned about poor performance relative to MySQLdb.
  • Attila Toth
    Attila Toth about 5 years
    in 2019, this answer helped me with this: stackoverflow.com/a/25724855/4530648