The "create table" case will have to be handled with one of the above
solutions that include "for". You can't create many tables with a single
statement.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello, i have a list of tables i want to drop:
user_tables =
drop_user_tables = """DROP TABLE IF EXISTS db2.%s"""
try:
cursor.execute(drop_user_tables, (x for x in user_tables))
thanks
This will create a serie of queries
DROP TABLE IF EXISTS db2.'notification'
Note the "single-quote" in the name, making it a constant, instead of a
variable.
You can use something like:
for sql in :
cursor.execute(sql)
try:
or
i.e. you can't just throw a generator expression at an SQL statement and
expect it to work.
DROP TABLE (and other DDL statements) don't technically take SQL parameters,
either, i.e. table names and the like cannot be passed as parameters.
thank you,
worked for me well.
i was unaware that DROP table did not take parameters.
again thanks
sorry, but what if i have this sql, how do i make it work?
The "create table" case will have to be handled with one of the above
solutions that include "for". You can't create many tables with a single
statement.