Re: Passing in parameters enclosed in double quotes

From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org, Federico Di Gregorio <fog(at)dndg(dot)it>, Brent Hoover <brent(at)thebuddhalodge(dot)com>
Subject: Re: Passing in parameters enclosed in double quotes
Date: 2011-11-18 16:49:42
Message-ID: 4EC68CA6.4040401@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 18/11/11 17:43, Adrian Klaver wrote:
> The only way I could get the substitution to work is:
> cur.execute("""select pg_get_serial_sequence(%s,%s)""",('"test 1"','id'))

This seems to be the only correct way to do it.

You want to call a function that accepts two text parameters, so you
need to use two Python strings as parameters. The first parameter is
'"test 1"' that is, a Python string containing "test 1". The second is
'id', that is a Python string containing id.

Cheers,
Jan

In response to

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2011-11-18 16:58:10 Re: Passing in parameters enclosed in double quotes
Previous Message Adrian Klaver 2011-11-18 16:43:49 Re: Passing in parameters enclosed in double quotes