Creating objects in thread created with subclass
Nick Arnett
narnett at mccmedia.com
Wed Apr 10 21:27:02 EDT 2002
> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Jeff Shannon
> Sent: Wednesday, April 10, 2002 1:07 PM
...
> Okay, first I should warn you that I don't know SQL and haven't
> used any DB modules yet, but... you need to dynamically *create*
> the string that you pass to execute, but that doesn't necessarily
> mean that you need to dynamically execute that string, if you get
> the difference. ;)
>
> Try something like this:
>
> mystring = "INSERT INTO Foo (fieldnames) VALUES (%s"
> mystring += ",%s" * (len(data)-2) + ")"
> self.dbh.execute(mystring, (data[1:]))
This approach does work... although I'm generating the '%s' series a bit
differently. Thanks for the help. I've never used this style of output
formatting and I'm still wrapping my brain around it. And I was initially
confused by figuring out how to make that MySQLdb, not Python's built-in,
was doing the formatting.
And thanks to Jeff Epler, too, for more-or-less the same solution.
And other Jeffs care to chime in?
Nick
More information about the Python-list
mailing list