views:

160

answers:

2

I'm writing an Fast-CGI application that makes use of sqlAlchemy & MySQL for persistent data storage. I have no problem connecting to the DB and setting up ORM (so that tables get mapped to classes); I can even add data to tables (in memory).

But, as soon as I query the DB (and push any changes from memory to storage) I get a 500 Internal Server Error and my error.log records malformed header from script. Bad header=FROM tags : index.py, when tags is the table name.

Any idea what could be causing this?

Also, I don't think it matters, but its a Linux development server talking to an off-site (across the country) MySQL server.

+2  A: 

Looks like SQLalchemy is pushing or echoing the query to your output (where fast-cgi) is instead looking for headers, then body. Maybe setting sqlalchemy.echo to False can help.

Alex Martelli
crgwbr
A: 

Instead of setting echo=True you can configure logging to output debugging information. SQLAlchemy has very flexible loggers hierarchy. The following lines will enable logging of the same info as echo does:

import logging

logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
Denis Otkidach