Created
January 7, 2017 00:52
-
-
Save rednebmas/6ea8cb5c8d85e325cc3777ef758cd79c to your computer and use it in GitHub Desktop.
Drop all tables from a SQLite database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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