From: <no...@so...> - 2002-09-28 13:45:04
|
Bugs item #611483, was opened at 2002-09-19 11:09 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=611483&group_id=16528 Category: PgSQL Group: None >Status: Closed Resolution: Invalid Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Gerhard Häring (ghaering) Summary: NULL not represented by Python None Initial Comment: According to the Database API 2.0, "SQL NULL values are represented by the Python None singleton on input and output." This doesn't seem to be the case: INSERT INTO "XXX" ("foo", "bar", "baz", "bop") VALUES ('boo', None, None, None) Traceback (most recent call last): File "XXX.py", line 90, in ? print XYZ_add() File "XXX.py", line 33, in ZZZ self.add_XYZ() File "XXX.py", line 25, in YYY self.cursor.execute(SQL) File "/usr/lib/python2.1/site-packages/pyPgSQL/PgSQL.py", line 2135, in execute raise OperationalError, msg libpq.OperationalError: ERROR: Attribute 'none' not found ---------------------------------------------------------------------- Comment By: Gerhard Häring (ghaering) Date: 2002-09-19 14:18 Message: Logged In: YES user_id=163326 Don't put None literally in SQL. If you want NULL in a SQL string, put NULL in ;-) You can, however, use Python Nones when binding parameters to your SQL statement, like this: cursor.execute(""" INSERT INTO MYTABLE (MYCOLUMN) VALUES (%s) """, (None,)) HTH ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=611483&group_id=16528 |