Creating objects in thread created with subclass

Jeff Epler jepler at unpythonic.net
Wed Apr 10 16:42:32 EDT 2002


On Tue, Apr 09, 2002 at 06:18:36PM -0700, Nick Arnett wrote:
> self.dbh.execute("INSERT INTO Foo (fieldnames) VALUES (%s,[%s])",(data[1:]))

Construct a string of as many "%s,..." as you need, substitute it into
the command you pass to .execute():

    format = ",".join(["%s"] * len(data[1:]))
    command = "INSERT INTO Foo (fieldnames) VALUES (%s)" % format
    self.dbh.execute(command, data[1:])

Jeff





More information about the Python-list mailing list