Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 919
Tony Avatar asked Mar 24 '09 15:03

Tony


People also ask

Which is better PyMySQL or MySQL connector?

Benchmarks. According to the following benchmarks, mysqlclient is faster (sometimes > 10x faster) than the pure Python clients. So looks like PyMySQL is still the way to go if using PyPy.

Can we use Python and MySQL together?

MySQL server will provide all the services required for handling your database. Once the server is up and running, you can connect your Python application with it using MySQL Connector/Python.

Is Python good for MySQL?

MySQL Connector/Python 8.0 is highly recommended for use with MySQL Server 8.0, 5.7, and 5.6.


2 Answers

You've looked at these?

http://wiki.python.org/moin/MySQL

like image 86
Adam Nelson Avatar answered Sep 25 '22 13:09

Adam Nelson


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

like image 30
Brendon Avatar answered Sep 21 '22 13:09

Brendon