> user_tables = ['notification', 'userNotification', 'product_comments', > 'product_donation_paypalTransaction', 'product_donation', > 'productList_recommended', 'productList_user_assoc', > 'profile_values'] > > drop_user_tables = """DROP TABLE IF EXISTS db2.%s""" > > try: > cursor.execute(drop_user_tables, (x for x in user_tables)) >
Norman, 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: http://docs.python.org/library/sqlite3.html#sqlite3.Cursor.executemany 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: cursor.executemany(drop_user_tables, user_tables) 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: cursor.execute(drop_user_tables, (table,))
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor