Re: Variable argument list for IN clause

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Sat, Sep 20, 2008 at 12:42:32PM +0200, Oswaldo Hernández wrote:
> Oswaldo Hernández escribió:
>> Hello,
> ...
>>
>
> Sorry, i have a silly day :)
>
> The solution is put the the args tuple as a simple parameters:
>
> >>> INparams = ("a", "b", "c")
> >>> SQL = "select 'a' in %s"
> >>> c.execute(SQL, (INparams,))
> >>> c.fetchall()
> [(True,)]

Yep. That's because psycopg will automatically adapt your tuple into
something that can be used in a "IN" clause. :)

federico
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.