diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-09-02 18:51:20 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-09-02 18:51:20 +0200 |
commit | 022985f098a206c3b7852fe08a798cd31623f10d (patch) | |
tree | 84a1a0b0a67fa95608641f8e47bd55e8c1cd11fb /update_sharing.py | |
parent | c0cd9df1e6cb63d524939028f5f6a07c2c8c3da5 (diff) | |
download | debian-dedup-022985f098a206c3b7852fe08a798cd31623f10d.tar.gz |
add option -d --database for db path to all scripts
Diffstat (limited to 'update_sharing.py')
-rwxr-xr-x | update_sharing.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/update_sharing.py b/update_sharing.py index 5ec6c7b..1ff0fd8 100755 --- a/update_sharing.py +++ b/update_sharing.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import optparse import sqlite3 from dedup.utils import fetchiter @@ -37,8 +38,7 @@ def process_pkgdict(cursor, pkgdict): insert_key = (pid1, pid2, fid1, fid2) add_values(cursor, insert_key, pkgnumfiles, pkgsize) -def main(): - db = sqlite3.connect("test.sqlite3") +def main(db): cur = db.cursor() cur.execute("PRAGMA foreign_keys = ON;") cur.execute("DELETE FROM sharing;") @@ -61,4 +61,9 @@ def main(): db.commit() if __name__ == "__main__": - main() + parser = optparse.OptionParser() + parser.add_option("-d", "--database", action="store", + default="test.sqlite3", + help="path to the sqlite3 database file") + options, args = parser.parse_args() + main(sqlite3.connect(options.database)) |