From e0ff07d7ef0fed42f937b81d076c96e293407e6d Mon Sep 17 00:00:00 2001 From: Jimmy Cao Date: Thu, 22 Dec 2011 17:27:33 -0600 Subject: [PATCH] changed database structure a bit --- var.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/var.py b/var.py index 69e2053..b7b4e64 100644 --- a/var.py +++ b/var.py @@ -185,9 +185,9 @@ with conn: 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, '+ - 'UNIQUE(player, roleid))')) + 'UNIQUE(player, role))')) @@ -209,12 +209,9 @@ def update_role_stats(acc, role, won, iwon): with conn: 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 "+ - "WHERE player=? AND roleid=?"), (acc, rid)) + "WHERE player=? AND role=?"), (acc, role)) row = c.fetchone() if row: wins, iwins, total = row @@ -228,7 +225,7 @@ def update_role_stats(acc, role, won, iwon): total += 1 c.execute("INSERT OR REPLACE INTO rolestats VALUES (?,?,?,?,?)", - (acc, rid, wins, iwins, total)) + (acc, role, wins, iwins, total))