tags:

views:

187

answers:

1

I have question about python and sqlite3. I want to drop a table from within Python. The command

cur.execute('drop table if exists tab1')

Does not work.

cur.executescript('drop table if exists tab1;')

does the job.

The execute method allows the creation of tables. However, it won't drop them? Is there a reason for this?

+1  A: 

The cur.executescript command issues a COMMIT before running the provided script. Additionally a CREATE executes a COMMIT intrinsically. Perhaps you have an open transaction that needs committed before your changes take place.

Travis Bradshaw
Thanks, that makes sense!
nwhsvc