[Tutor] Pouring a list into a dictionary then into database
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Mon Sep 29 20:57:42 EDT 2003
On Mon, 29 Sep 2003, Allen wrote:
> > you can also call the executemany() method to do this operation on your
> > whole list of key/value pairs. So you should be able to say:
> >
> > ###
> > sql = "replace into tablename %s values (%s)"
> > crsr.executemany(zip(headings, foundData))
> > ###
>
> So where does the sql go??
Hi Allen,
... Doh. Good question. My bad.
I should have written:
###
sql = "replace into tablename %s values (%s)"
crsr.executemany(sql, zip(headings, foundData))
###
instead. My apologies!
I do have a good defense though: ignorance! *grin* The reason I couldn't
test this code is because I'm not familiar at all with REPLACE and wasn't
able to run it on a test database. I'm only familiar with INSERT, UPDATE,
DELETE, and SELECT. Is REPLACE part of the SQL standard?
Talk to you later!
More information about the Tutor
mailing list