Re: [psycopg] Solving the SQL composition problem - Mailing list psycopg

From Adrian Klaver
Subject Re: [psycopg] Solving the SQL composition problem
Date
Msg-id f7cc0d30-7edc-285a-45f3-4c66febf19b4@aklaver.com
Whole thread Raw
In response to Re: [psycopg] Solving the SQL composition problem  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List psycopg
On 01/02/2017 07:05 AM, Jim Nasby wrote:
> On 1/1/17 2:11 AM, Daniele Varrazzo wrote:
>>         sql.SQL("insert into %s values (%%s)") %
>> [sql.Identifier('mytable')],
>
> Since %s isn't standard parameter replacement anyway, I'm wondering if
> both considerations could just be handled by execute(), by using
> different replacement syntax. IE:

I thought it was?:

https://www.python.org/dev/peps/pep-0249/#paramstyle

format     ANSI C printf format codes, e.g. ...WHERE name=%s

>
> execute('insert into %s values ($1)', [42], ['my table'])
>
> Obviously this would be backwards incompatible, but I think that's
> manageable.


--
Adrian Klaver
adrian.klaver@aklaver.com


psycopg by date:

Previous
From: Jim Nasby
Date:
Subject: Re: [psycopg] Solving the SQL composition problem
Next
From: Adrian Klaver
Date:
Subject: Re: [psycopg] speed concerns with executemany()