psycopg2 weirdness

Tino Wildenhain tino at
Sat Jan 17 19:43:03 CET 2009

Neha Gupta wrote:
> Hey,
> crs_dep_hour, origin from flightdata where date = '" + date + "' group

never ever do that! Even more when input comes from user.
The correct form is cur.exec("... date = %s group by ...",(date,))

please see dbapi2 documentation or examples which come with


> You can see above that I even ignored the date passed from the form
> and I have hardcoded '01-05-2007'. The message "About to issue query"
> gets printed as well as the right date chosen from the date picker but
> then I see the following:
> Assertion failed: (str != NULL), function PyString_FromString, file
> Objects/stringobject.c, line 107.
> Abort trap
> with a pop that says: "The application Python quit unexpectedly. The
> problem may have been caused by the plug-in".
> --
> I don't understand the error message above. The date did get passed
> correctly and am now not even using it, I use the hard coded date. So
> what is going on?

Do other querys work within your application? Looks like the
components of the db layer are not correctly found. This can
happen if the environment of the web server differs from
your personal user when you are testing your scripts.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <>

More information about the Python-list mailing list