[FRPythoneers] Object-relational mapper for Python and MySQL?

Vince Dean vdean at ucar.edu
Wed Feb 25 15:13:14 MST 2009

I'd appreciate suggestions for Python tools to simplify queries
against a MySQL database.

I am writing a number of reports in Python against a MySQL
database, using MySQLdb.  Not surprisingly, I'm writing a
lot of boilerplate Python and SQL.

I know that there are a number of Python modules to support
this sort of work (SQLAlchemy, SQLOject, Django, etc.), and
I'd welcome thoughts on which might be my best fit.  Here is
our situation.

* I'm doing queries only; the data is maintained by another
(Java) application.

* Efficiency is not a big issue.  The system has few users
and the reports are run infrequently.  Ease of development is
a bigger concern.

* The database already exists; I cannot change column or table
names to conform to a convention.

* It's not a small database.  We have 123 tables and 770
columns, but I am writing queries against a relatively small
fraction of them.

* Queries frequently involve four or more tables.  Some of
the logic is easily handled by SQL joins; other parts require
program logic to navigate through the relationships.

* It would be useful, but not essential, if the tool could
extract some of the data model it needs directly from the
database schema.

* I just need a tool to help with the database queries and return
the results to Python, for some pretty simple text reports.
I'm not building a Web application.

Any thoughts?


More information about the FRPythoneers mailing list