Skip to content

Instantly share code, notes, and snippets.

@rednebmas
Created January 7, 2017 00:52
Show Gist options
  • Save rednebmas/6ea8cb5c8d85e325cc3777ef758cd79c to your computer and use it in GitHub Desktop.
Save rednebmas/6ea8cb5c8d85e325cc3777ef758cd79c to your computer and use it in GitHub Desktop.
Drop all tables from a SQLite database
try:
db.execute("CREATE TABLE Test (test_id INTEGER NOT NULL);")
db.execute("INSERT INTO Test (test_id) VALUES (1);")
tables = db.select(table="sqlite_master", where="type = 'table'", columns="name")
self.assertTrue(len(tables) == 1)
for table in tables:
db.execute("DROP TABLE " + table['name'])
tables = db.select(table="sqlite_master", where="type = 'table'", columns="name")
self.assertTrue(len(tables) == 0)
except Exception as e:
self.assertTrue(False, e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment