Skip to content
Advertisement

Python and MySQL: is there an alternative to MySQLdb?

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.

Advertisement

Answer

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.

Advertisement