Bigger digits for Emergo and Avalam
[vchess.git] / server / db / sync_gamestat.py
CommitLineData
4a209313
BA
1#!/usr/bin/env python
2
3# Manually (for now: TODO) add an entry in GameStat when a variant is added
4
5from dbconnect import create_connection
6
7def sync_gamestat():
8 """
9 (Incrementally) Synchronize GameStat table from Variants update
10 """
11
12 conn = create_connection()
13 cur = conn.cursor()
14
15 cur.execute("SELECT max(vid) FROM GameStat");
16 vid_max = cur.fetchone()[0] or 0
17 cur.execute("SELECT id FROM Variants WHERE id > ?", (vid_max,))
18 rows = cur.fetchall()
19 for variant in rows:
20 cur.execute("INSERT INTO GameStat(vid) VALUES (?)", (variant[0],))
21
22 conn.commit()
23 cur.close()
24
25sync_gamestat()