Psycopg2 SyntaxError: invalid syntax on "INSERT INTO" database

MRAB python at mrabarnett.plus.com
Thu Jan 10 02:11:59 CET 2013


On 2013-01-10 00:19, andydtaylor at gmail.com wrote:
> Hi John,
>
> He're the code I would like to see work. The cursor_to is an oversight. I extracted this element from some other code in an attempt to isolate/resolve the problem myself, hence having a simplified table version. Which works actually, but unfortunately that's not educating me suffieciently. Actual error message I see follows.
>
[snip]

> - - - - - - - - - - - - - - - - - - - - - - - - -
> Error Message:
>
> andyt at andyt-ThinkPad-X61:~/projects/django-stringer/Other/TFLJPAPI$ python creat_db_exp.py
>    File "creat_db_exp.py", line 15
>      cursor.execute("INSERT INTO tubecross (station_code, SAJ, SPB, SOQ) VALUES (%s, %s, %s, %s)",(SAJ, 00:00, 00:22, 00:27))
>                                                                                                           ^
> SyntaxError: invalid syntax
>
"00:00", etc, aren't valid Python, they're two ints with a colon
between them.

You need to determine what Python class to use to represent those.



More information about the Python-list mailing list