thr
thr

Reputation: 19476

MySQL-db lib for Python 3.x?

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

Upvotes: 36

Views: 44204

Answers (9)

Collin Anderson
Collin Anderson

Reputation: 15484

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

Upvotes: 4

davispuh
davispuh

Reputation: 1433

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/

Upvotes: 7

itsadok
itsadok

Reputation: 29352

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.

Upvotes: 34

Zsolti
Zsolti

Reputation: 1607

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

Upvotes: 2

Artur Czajka
Artur Czajka

Reputation: 18321

There is an official Python 2/3 library, downloadable from MySQL website. Oracle released version 1.0.7 to public on 29 September 2012.

It's pure Python and works with MySQL 4.1+

See more details here: http://dev.mysql.com/doc/connector-python/en/connector-python.html

I'm currently using it with MySQL 5.5 and Python 3.2 with no problems thus far :)

Upvotes: 0

You can download the mysql-connector-python module compatible with Python3:

http://rpm.pbone.net/index.php3/stat/4/idpl/15667200/dir/rawhide/com/mysql-connector-python3-0.3.2-2.fc16.noarch.rpm.html

Get the "source RPM", unzip it and use it (e.g. put it in your PYTHONPATH, and look at the examples).

Upvotes: 1

user175889
user175889

Reputation:

not sure if you're still looking, but you could try this: http://sourceforge.net/projects/mypysql/

Upvotes: 1

Benjamin Peterson
Benjamin Peterson

Reputation: 20580

You're probably better off using Python 2.x at the moment. It's going to be a while before all Python packages are ported to 3.x, and I expect writing a library or application with 3.x at the moment would be quite frustrating.

Upvotes: 0

Paul Oyster
Paul Oyster

Reputation: 2006

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

Upvotes: 2

Related Questions