Alex Rivera | Logout

Python and MySQL: is there an alternative to MySQLdb?

Asked 2009-03-24T15:04:09.817
16

Is there a module written purely in Python that will allow a script to communicate with a MySQL database? I've already tried MySQLdb without success. It requires too much: GCC, zlib, and openssl. I do not have access to these tools; even if I did, I don't want to waste time getting them to work together. I'm looking for tools that will make my work easier.

Can someone point me in the direction of a MySQL Python module written in Python? If not, tips on writing my own code for communicating with MySQL would be appreciated.

Thanks,

Tony


Thanks everyone for your answers. Since I'm working with a small database (a few hundred records, mainly names and addresses) I've decided to use SQLite. I just discovered it. It seems to be perfectly suited for my purposes; it was simple to install (took about two minutes) and works well with Python. I'm stuck with Python 2.4 so I can't use the sqlite3 module, but I'm able to communicate with the database by using Python's 'subprocess.Popen' function and command-line parameters.

Edit
Report

4 Answers

5

Lately there is also oursql (docs), which has various advantages over MySQLdb and other existing drivers -- listed at the top of the documentation.

answered 2009-11-30T18:50:18.447
4

Oracle implemented a pure python mysql connector, aptly named mysql-connector-python. It can be pip-installed and receives plenty of updates.

Note that it's GPL licensed, which may or may not be a problem for your prjoect. If you can't live with that, you can also pick up PyMySQL instead which is one of the few connectors that works well and is distributed under MIT.

answered 2009-03-24T16:40:39.260
2

As mentioned in earlier answer, MySQL Connector/Python implements the MySQL Server/Client completely in Python. No compiling, just installing.

Here are the links:
* https://launchpad.net/myconnpy
* code: https://code.launchpad.net/myconnpy
* download: https://launchpad.net/myconnpy/+download (development shapshots)

It's not complete yet, but it should have enough to keep you going. (FYI, I am the maintainer)

answered 2009-12-01T07:34:11.353
0

As far as I know there is no direct alternative. The only thing I can think of is to use ODBC instead, via pyodbc. The MySQL site has an ODBC connector you can download. But I've never used this approach myself, so I can't say how well it will work.

answered 2009-03-24T15:12:02.170

Your Answer