Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drop table in python with sqlite3

Tags:

python

sqlite

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?

like image 438
nwhsvc Avatar asked Jan 13 '10 20:01

nwhsvc


1 Answers

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.

like image 173
Travis Bradshaw Avatar answered Oct 23 '22 18:10

Travis Bradshaw