From 1f8999ff08eea3d17eba6faf4ecd0559e10af9ef Mon Sep 17 00:00:00 2001 From: Changaco Date: Tue, 30 Jan 2018 17:15:59 +0100 Subject: [PATCH] add a `--pragma` argument to tar2sqlite This allows experimenting different SQLite pragmas to see if they can increase speed. --- legi/tar2sqlite.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/legi/tar2sqlite.py b/legi/tar2sqlite.py index 556867f..b5c5b21 100755 --- a/legi/tar2sqlite.py +++ b/legi/tar2sqlite.py @@ -454,6 +454,8 @@ def main(): p.add_argument('--anomalies', action='store_true', default=False, help="detect anomalies after each processed archive") p.add_argument('--anomalies-dir', default='.') + p.add_argument('--pragma', action='append', default=[], + help="Doc: https://www.sqlite.org/pragma.html | Example: journal_mode=WAL") p.add_argument('--raw', default=False, action='store_true') args = p.parse_args() @@ -461,6 +463,10 @@ def main(): os.mkdir(args.anomalies_dir) db = connect_db(args.db) + for pragma in args.pragma: + query = "PRAGMA " + pragma + result = db.one(query) + print("> Sent `%s` to SQLite, got `%s` as result" % (query, result)) # Look for new archives in the given directory last_update = db.one("SELECT value FROM db_meta WHERE key = 'last_update'")