I'm trying to make a function to drop all the tables in the current database. This is what I have:
def drop_tables (self):
cur.execute ("SELECT name FROM sqlite_master WHERE type='table';")
tlist = cur.fetchall()
with conn:
for t in tlist:
cur.execute ('DROP TABLE ?;', t[0])
Which yields the following error:
File "/storage/sdcard0/com.hipipal.qpyplus/.last_tmp.py", line 170, in drop_tables
cur.execute ('DROP TABLE ?;', t[0])
sqlite3.OperationalError: near "?": syntax error
It's a sqlite3 error, not a python error. Can I not have the cursor substitute like this? Is there any other way to achieve this; other then deleting the database? (And I don't know if the "with" statement is required for a DROP, but I get the error regardless)
Thank you