diff options
author | 2017-08-04 19:23:18 +1000 | |
---|---|---|
committer | 2017-08-04 19:23:18 +1000 | |
commit | b97e374cdbc7988e193f6377f2604f1d4b6264ea (patch) | |
tree | 24d9b899f6c086a4f0135e3ef96ffa3867da2799 /scripts/minimaws/lib/dbaccess.py | |
parent | 3eb9ddfa1691ce147861a2648e34dc7478f8f3b8 (diff) |
minimaws: expose system BIOS, better way of dropping tables
Diffstat (limited to 'scripts/minimaws/lib/dbaccess.py')
-rw-r--r-- | scripts/minimaws/lib/dbaccess.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/minimaws/lib/dbaccess.py b/scripts/minimaws/lib/dbaccess.py index d453fe3d941..3366d6f7eb5 100644 --- a/scripts/minimaws/lib/dbaccess.py +++ b/scripts/minimaws/lib/dbaccess.py @@ -542,9 +542,14 @@ class UpdateConnection(object): def prepare_for_load(self): # here be dragons - this is a poor man's DROP ALL TABLES etc. - self.dbconn.execute('PRAGMA writable_schema = 1') - self.dbconn.execute('delete from sqlite_master where type in (\'table\', \'index\', \'trigger\')') - self.dbconn.execute('PRAGMA writable_schema = 0') + self.dbconn.execute('PRAGMA foreign_keys = OFF') + for query in self.dbconn.execute('SELECT \'DROP INDEX \' || name FROM sqlite_master WHERE type = \'index\' AND NOT name GLOB \'sqlite_autoindex_*\'').fetchall(): + self.dbconn.execute(query[0]) + for query in self.dbconn.execute('SELECT \'DROP TABLE \' || name FROM sqlite_master WHERE type = \'table\'').fetchall(): + self.dbconn.execute(query[0]) + self.dbconn.execute('PRAGMA foreign_keys = ON') + + # this is where the sanity starts for query in SchemaQueries.DROP_INDEXES: self.dbconn.execute(query) for query in SchemaQueries.CREATE_TABLES: |