changed database structure a bit
This commit is contained in:
parent
5279e36a3f
commit
497876cbfa
11
var.py
11
var.py
@ -185,9 +185,9 @@ with conn:
|
|||||||
c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,))
|
c.execute("INSERT OR REPLACE INTO roles (role) VALUES (?)", (x,))
|
||||||
|
|
||||||
|
|
||||||
c.execute(('CREATE TABLE IF NOT EXISTS rolestats (player TEXT, roleid INTEGER, '+
|
c.execute(('CREATE TABLE IF NOT EXISTS rolestats (player TEXT, role TEXT, '+
|
||||||
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
'teamwins SMALLINT, individualwins SMALLINT, totalgames SMALLINT, '+
|
||||||
'UNIQUE(player, roleid))'))
|
'UNIQUE(player, role))'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -210,11 +210,8 @@ def update_role_stats(acc, role, won, iwon):
|
|||||||
with conn:
|
with conn:
|
||||||
wins, iwins, totalgames = 0, 0, 0
|
wins, iwins, totalgames = 0, 0, 0
|
||||||
|
|
||||||
c.execute('SELECT id FROM roles WHERE role=?', (role,))
|
|
||||||
rid = c.fetchone()[0]
|
|
||||||
|
|
||||||
c.execute(("SELECT teamwins, individualwins, totalgames FROM rolestats "+
|
c.execute(("SELECT teamwins, individualwins, totalgames FROM rolestats "+
|
||||||
"WHERE player=? AND roleid=?"), (acc, rid))
|
"WHERE player=? AND role=?"), (acc, role))
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
if row:
|
if row:
|
||||||
wins, iwins, total = row
|
wins, iwins, total = row
|
||||||
@ -228,7 +225,7 @@ def update_role_stats(acc, role, won, iwon):
|
|||||||
total += 1
|
total += 1
|
||||||
|
|
||||||
c.execute("INSERT OR REPLACE INTO rolestats VALUES (?,?,?,?,?)",
|
c.execute("INSERT OR REPLACE INTO rolestats VALUES (?,?,?,?,?)",
|
||||||
(acc, rid, wins, iwins, total))
|
(acc, role, wins, iwins, total))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user