From: | Damon Fasching <fasching(at)design(dot)lbl(dot)gov> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | executemany with select |
Date: | 2002-03-05 03:13:38 |
Message-ID: | Pine.SOL.3.96.1020304190531.18973F-100000@design.lbl.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi,
If executemany(queryString, sequence) is used with a SELECT query, as in
the example below, it seems that the cursor retains only the data from the
last member of sequence. Can someone verify this? No big deal, just
trying to get my usage correct.
Thanks,
Damon
## ===================================================================
import psycopg
conn = psycopg.connect('testdb')
curs = conn.cursor()
curs.execute("CREATE TABLE testtb (key int4, data text)")
s = ((0, 'row1'), (1, 'row2'))
curs.executemany("INSERT INTO testtb VALUES (%d, %s)", s)
keys = ((0,), (1,))
curs.executemany("SELECT name FROM testtb WHERE key = %d", keys)
rows = curs.fetchall()
for row in rows: print row, "\n"
## ==================================================================
produces the output
>>> ('row2',)
---------
May the lights in The Land of Plenty
shine on the Truth some day L Cohen
From | Date | Subject | |
---|---|---|---|
Next Message | Hargis | 2002-03-05 05:01:28 | Optimizer and Indexes with Joins |
Previous Message | Clinton Adams | 2002-03-05 00:53:54 | Re: Do Stored Procedures exist (Besides FUNCTIONs) |