From f24f3866b5cc5ccf0eaf32489892e14f6d94f899 Mon Sep 17 00:00:00 2001 From: Jeff Armstrong Date: Sat, 27 Jul 2013 14:33:37 -0400 Subject: database --- src/room.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/room.py') diff --git a/src/room.py b/src/room.py index 0db88ca..1bc3747 100644 --- a/src/room.py +++ b/src/room.py @@ -1,13 +1,19 @@ import json - +import sqlite3 def get_room(id): ret = None - with open(str(id)+".json", "r") as f: - jsontext = f.read() + + con = sqlite3.connect("game.db") + + for row in con.execute("select json from rooms where id=?",(id,)): + + jsontext = row[0] d = json.loads(jsontext) d['id'] = id ret = Room(**d) + break + return ret class Room(): -- cgit v1.2.3