changes to allow hud to use stylekey and aggregate stats query

This commit is contained in:
sqlcoder
2009-05-21 21:27:44 +01:00
parent d986966332
commit 07247de030
2 changed files with 96 additions and 81 deletions
+12 -9
View File
@@ -191,15 +191,14 @@ class Database:
winners[row[0]] = row[1]
return winners
def get_stats_from_hand(self, hand, aggregate = False):
def get_stats_from_hand(self, hand, aggregate = False, stylekey = 'A000000'):
c = self.connection.cursor()
if aggregate:
query = 'get_stats_from_hand_aggregated'
subs = (hand, hand, hand)
else:
query = 'get_stats_from_hand'
subs = (hand, hand)
subs = (hand, hand, stylekey, stylekey)
# now get the stats
c.execute(self.sql.query[query], subs)
@@ -218,7 +217,10 @@ class Database:
c = self.connection.cursor()
c.execute(self.sql.query['get_player_id'], {'player': player_name, 'site': site})
row = c.fetchone()
return row[0]
if row:
return row[0]
else:
return None
if __name__=="__main__":
c = Configuration.Config()
@@ -234,16 +236,17 @@ if __name__=="__main__":
print "last hand = ", h
hero = db_connection.get_player_id(c, 'PokerStars', 'nutOmatic')
print "nutOmatic is id_player = %d" % hero
if hero:
print "nutOmatic is id_player = %d" % hero
stat_dict = db_connection.get_stats_from_hand(h)
for p in stat_dict.keys():
print p, " ", stat_dict[p]
print "nutOmatics stats:"
stat_dict = db_connection.get_stats_from_hand(h, hero)
for p in stat_dict.keys():
print p, " ", stat_dict[p]
#print "nutOmatics stats:"
#stat_dict = db_connection.get_stats_from_hand(h, hero)
#for p in stat_dict.keys():
# print p, " ", stat_dict[p]
print "cards =", db_connection.get_cards(73525)
db_connection.close_connection