psycopg problem

Started by Roger Masonover 19 years ago3 messagesgeneral
Jump to latest
#1Roger Mason
rmason@esd.mun.ca

Hello,

I'm trying to use psycopg2 to create tables in a database using:

run = "S90040"
curs.execute("create table %s (date text, tset text)",(run,))

but it fails with

Traceback (most recent call last):
File "write_xy_to_pg_psyco.py", line 44, in ?
curs.execute("create table %s (date text, tset text)",(run,))
psycopg2.ProgrammingError: syntax error at or near "'S90040'" at
character 14

If I run

curs.execute("create table S90040 (date text, tset text)",(run,))

it works perfectly, so I assume the quoting is messed up.

Could someone please tell me what I'm doing wrong?

Thanks,

Roger Mason

#2Volkan YAZICI
yazicivo@ttnet.net.tr
In reply to: Roger Mason (#1)
Re: psycopg problem
#3Roger Mason
rmason@esd.mun.ca
In reply to: Volkan YAZICI (#2)
Re: psycopg problem

Volkan YAZICI <yazicivo@ttnet.net.tr> writes:

On Aug 10 07:57, Roger Mason wrote:

run = "S90040"
curs.execute("create table %s (date text, tset text)",(run,))

Please see this[1] and this[2].

[1] http://archives.postgresql.org/pgsql-general/2006-07/msg00706.php
[2] http://archives.postgresql.org/pgsql-general/2006-07/msg00707.php

Thanks very much. I should have found this myself!

Roger