Work around error with no database

Instead of blindly trusting that SELECT ... works, use try-catch to get
around errors when the database doesn't have the tables yet.
This commit is contained in:
Mika Bostrom 2009-07-06 09:01:49 +03:00
parent dd4aeffa4f
commit b7ca7a77a7

View File

@ -72,6 +72,7 @@ class Database:
cur = self.connection.cursor() cur = self.connection.cursor()
self.hand_1day_ago = 0 self.hand_1day_ago = 0
try:
cur.execute(self.sql.query['get_hand_1day_ago']) cur.execute(self.sql.query['get_hand_1day_ago'])
row = cur.fetchone() row = cur.fetchone()
if row and row[0]: if row and row[0]:
@ -85,6 +86,8 @@ class Database:
self.hand_nhands_ago = 0 # todo self.hand_nhands_ago = 0 # todo
#cur.execute(self.sql.query['get_table_name'], (hand_id, )) #cur.execute(self.sql.query['get_table_name'], (hand_id, ))
#row = cur.fetchone() #row = cur.fetchone()
except: # no tables created yet
pass
self.saveActions = False if self.import_options['saveActions'] == False else True self.saveActions = False if self.import_options['saveActions'] == False else True
def do_connect(self, c): def do_connect(self, c):