entropy.db: doDatabaseExport, make possible to exclude tables

This commit is contained in:
Fabio Erculiani
2009-05-31 10:15:03 +02:00
parent ab66d84f67
commit dfd6dd5aff

View File

@@ -3959,7 +3959,11 @@ class LocalRepository:
retcode = subprocess.call(sqlite3_exec, shell = True)
return retcode
def doDatabaseExport(self, dumpfile, gentle_with_tables = True):
def doDatabaseExport(self, dumpfile, gentle_with_tables = True,
exclude_tables = None):
if not exclude_tables:
exclude_tables = []
dumpfile.write("BEGIN TRANSACTION;\n")
self.cursor.execute("SELECT name, type, sql FROM sqlite_master WHERE sql NOT NULL AND type=='table'")
@@ -3985,6 +3989,9 @@ class LocalRepository:
sql = "CREATE TABLE IF NOT EXISTS"+sql[len(t_cmd):]
dumpfile.write("%s;\n" % sql)
if name in exclude_tables:
continue
self.cursor.execute("PRAGMA table_info('%s')" % name)
cols = [str(r[1]) for r in self.cursor.fetchall()]
q = "SELECT 'INSERT INTO \"%(tbl_name)s\" VALUES("