Re: Solving the SQL composition problem

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: Solving the SQL composition problem
Date: 2017-01-02 15:16:32
Message-ID: f7cc0d30-7edc-285a-45f3-4c66febf19b4@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)klaver(at)aklaver(dot)com

In response to

Browse psycopg by date

  From Date Subject
Next Message Adrian Klaver 2017-01-02 15:21:39 Re: speed concerns with executemany()
Previous Message Jim Nasby 2017-01-02 15:05:16 Re: Solving the SQL composition problem