-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
33 lines (27 loc) · 889 Bytes
/
setup.py
File metadata and controls
33 lines (27 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sqlite3
def setup_db(db_name):
conn = sqlite3.connect(db_name)
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS songs (
song_id INTEGER PRIMARY KEY AUTOINCREMENT,
song_name TEXT UNIQUE NOT NULL,
file_path TEXT,
song_duration REAL
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS fingerprints (
hash_value TEXT NOT NULL, -- Or INTEGER if your hashes are numeric
song_id INTEGER NOT NULL,
offset REAL NOT NULL, -- Store time in seconds
FOREIGN KEY (song_id) REFERENCES songs (song_id)
)
''')
cursor.execute('''
CREATE INDEX IF NOT EXISTS idx_hash_value ON fingerprints (hash_value)
''')
conn.commit()
conn.close()
if __name__ == '__main__':
setup_db('limittest_database.db')