Commit | Line | Data |
---|---|---|
4a209313 BA |
1 | #!/usr/bin/env python |
2 | ||
3 | # Manually (for now: TODO) add an entry in GameStat when a variant is added | |
c82cd86a | 4 | # TODO: also delete lines in GameStat not matching a variant (removed ones...) |
4a209313 BA |
5 | |
6 | from dbconnect import create_connection | |
7 | ||
8 | def sync_gamestat(): | |
9 | """ | |
10 | (Incrementally) Synchronize GameStat table from Variants update | |
11 | """ | |
12 | ||
13 | conn = create_connection() | |
14 | cur = conn.cursor() | |
15 | ||
16 | cur.execute("SELECT max(vid) FROM GameStat"); | |
17 | vid_max = cur.fetchone()[0] or 0 | |
18 | cur.execute("SELECT id FROM Variants WHERE id > ?", (vid_max,)) | |
19 | rows = cur.fetchall() | |
20 | for variant in rows: | |
21 | cur.execute("INSERT INTO GameStat(vid) VALUES (?)", (variant[0],)) | |
22 | ||
23 | conn.commit() | |
24 | cur.close() | |
25 | ||
26 | sync_gamestat() |