diff options
author | Michaël Ball <michael.ball@gmail.com> | 2015-12-20 15:22:16 +0000 |
---|---|---|
committer | Michaël Ball <michael.ball@gmail.com> | 2015-12-20 15:29:39 +0000 |
commit | 3f14c56860ff67e2d2a689fe3f362ad7a25631d5 (patch) | |
tree | 6ac2d39fd268231f4f7ebdf8a41661c27b89101e /db | |
parent | f0b11a127a127a91217fcd5645c772ce37b2bfcf (diff) |
Syntax improvements
Diffstat (limited to 'db')
-rw-r--r-- | db/db_manager.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/db/db_manager.py b/db/db_manager.py index c55ac39..f9b10c3 100644 --- a/db/db_manager.py +++ b/db/db_manager.py @@ -1,7 +1,6 @@ import configparser import os import sqlite3 -import tempfile class DbManager: @@ -32,18 +31,16 @@ class DbManager: yield("{0};".format(sql)) table_name_ident = table_name.replace("\"", "\"\"") - res = cu.execute( - "PRAGMA table_info(\"{0}\")".format(table_name_ident)) + res = cu.execute("PRAGMA table_info(\"{0}\")".format( + table_name_ident)) column_names = [ str(table_info[1]) for table_info in res.fetchall()] q = """ SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}"; - """.format( - table_name_ident, - ",".join( - """'||quote("{0}")||'""".format( - col.replace( - "\"", "\"\"")) for col in column_names)) + """.format(table_name_ident, ",".join( + """'||quote("{0}")||'""".format( + col.replace( + "\"", "\"\"")) for col in column_names)) query_res = cu.execute(q) for row in query_res: yield("{0};".format(row[0])) @@ -82,7 +79,7 @@ class DbManager: self.conn.row_factory = sqlite3.Row - def __del__(self): + def export(self): if not os.path.isfile(self.config["DEFAULT"]["database"]): script = "" |