Re: Passing in parameters enclosed in double quotes
От | Federico Di Gregorio |
---|---|
Тема | Re: Passing in parameters enclosed in double quotes |
Дата | |
Msg-id | 4EC68EA2.5050204@dndg.it обсуждение исходный текст |
Ответ на | Re: Passing in parameters enclosed in double quotes (Adrian Klaver <adrian.klaver@gmail.com>) |
Ответы |
Re: Passing in parameters enclosed in double quotes
|
Список | psycopg |
On 18/11/11 17:43, Adrian Klaver wrote: > On Friday, November 18, 2011 7:37:32 am Federico Di Gregorio wrote: >> > On 18/11/11 16:31, Brent Hoover wrote: [snip] > I was following along and tried the above and it did not work for me. > > On Postgres end: > > CREATE table "test 1" (id serial, fld_1 text); > > test(5432)aklaver=>\d "test 1" > Table "public.test 1" > Column | Type | Modifiers > --------+---------+------------------------------------------------------- > id | integer | not null default nextval('"test 1_id_seq"'::regclass) > fld_1 | text | > > > > test(5432)aklaver=>select pg_get_serial_sequence('"test 1"','id'); > pg_get_serial_sequence > ------------------------ > public."test 1_id_seq" > > > On Psycopg2 end: > > cur.execute("""select pg_get_serial_sequence(%s,%s)""",(AsIs('"test 1"'),'id')) > ProgrammingError: column "test 1" does not exist > LINE 1: select pg_get_serial_sequence("test 1",E'id') > > cur.execute("""select pg_get_serial_sequence(%s,%s)""",(AsIs("test 1"),'id')) > ProgrammingError: syntax error at or near "1" > LINE 1: select pg_get_serial_sequence(test 1,E'id') > > The only way I could get the substitution to work is: > cur.execute("""select pg_get_serial_sequence(%s,%s)""",('"test 1"','id')) > rs=cur.fetchall() > rs > [('public."test 1_id_seq"',)] Given your example query in psql that's correct. -- Federico Di Gregorio fog@initd.org "Yes, your honour, I have RSA encryption code tattood on my penis. Shall I show the jury?" -- <dark>
В списке psycopg по дате отправления: