From dfd6dd5aff62f4f4914d73c14dcd58a31a01faf0 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 31 May 2009 10:15:03 +0200 Subject: [PATCH] entropy.db: doDatabaseExport, make possible to exclude tables --- libraries/entropy/db.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/entropy/db.py b/libraries/entropy/db.py index 645c060b6..a6d63ae5b 100644 --- a/libraries/entropy/db.py +++ b/libraries/entropy/db.py @@ -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("