Re: executemany question

Gerhard Häring <[email protected]>
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
Steve Waterbury wrote:
> Gerhard Häring wrote:
>> executemany is not supposed to be used with SELECTs. Use it for INSERT 
>> or UPDATE only.
> 
> Thanks ... I realized that right after I send my
> question!  :^)
> 
>> [...]
>> In your particular example:
>>
>> docnums = [3,4,5,6]
>> curs.execute("select * from docs where doc_number in %s", (docnums,))
> 
> 
> That doesn't seem to work either: [...]

Sorry, I meant to use a tuple instead of a list. So pyPgSQL will invoke 
repr() on the parameter before inserting it into the SQL. AFAIC this 
will currently work fine for ints and floats, but not much else. Also 
note that this is one thing that won't work in other adapters like for 
Oracle.

But you can always construct your SQL with the appropriate IN-clause 
manually.

-- Gerhard



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
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.