Merge pull request #3 from yang/index-hash

Create index on hash
This commit is contained in:
Łukasz Langa 2013-10-17 10:12:48 -07:00
commit 24f76c0678

View File

@ -70,12 +70,12 @@ def get_sqlite3_cursor(path, copy=False):
conn = sqlite3.connect(path)
atexit.register(conn.close)
cur = conn.cursor()
for name, in cur.execute('SELECT name FROM sqlite_master'):
if name == 'bitrot':
break
else:
names = set(name for name, in cur.execute('SELECT name FROM sqlite_master'))
if 'bitrot' not in names:
cur.execute('CREATE TABLE bitrot (path TEXT PRIMARY KEY, '
'mtime INTEGER, hash TEXT, timestamp TEXT)')
if 'bitrot_hash_idx' not in names:
cur.execute('CREATE INDEX bitrot_hash_idx ON bitrot (hash)')
return conn