Skip to content

Commit

Permalink
add a --pragma argument to tar2sqlite
Browse files Browse the repository at this point in the history
This allows experimenting different SQLite pragmas to see if they can increase speed.
  • Loading branch information
Changaco committed Jan 31, 2018
1 parent 7f82f6b commit 1f8999f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions legi/tar2sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,19 @@ 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()

if not os.path.isdir(args.anomalies_dir):
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'")
Expand Down

0 comments on commit 1f8999f

Please sign in to comment.