[Tutor] what is wrong with this code?
zstumgoren at gmail.com
Mon Apr 26 19:18:54 CEST 2010
> user_tables = ['notification', 'userNotification', 'product_comments',
> 'product_donation_paypalTransaction', 'product_donation',
> 'productList_recommended', 'productList_user_assoc',
> drop_user_tables = """DROP TABLE IF EXISTS db2.%s"""
> cursor.execute(drop_user_tables, (x for x in user_tables))
It looks like what you're after is the cursor's "executemany" method, which
is supported by many common database adapters that comply with DB-API2.0.
If you're using sqlite3, there are more details here:
In your code, you seem to be trying to loop over the values in the
user_tables list. I haven't tested this, but instead try simply passing the
list of user_tables to executemany:
If the above doesn't work or is not available with your database adapter,
how about just using a simple loop?
for table in user_tables:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor