From 4f555e2d8f8007c44b0edbb4b59bfe8e5a341bc6 Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 8 Jun 2009 18:19:55 +0800 Subject: [PATCH] Hand.insert() update - low hanging fruit --- pyfpdb/Hand.py | 11 +++++------ pyfpdb/fpdb_db.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 879dad85..129eaede 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -92,16 +92,14 @@ db: a connected fpdb_db object""" # HandsActions - all actions for all players for all streets - self.actions # BoardCards - Skip - no longer necessary? # Hands - Summary information of hand indexed by handId - gameinfo - # self.tablename = tableName - # self.handid = siteHandNo + hh['siteHandNo'] = self.handid # gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), # - # self.starttime = handStart - # importTime DATETIME NOT NULL, - # + hh['handStart'] = self.starttime # seats TINYINT NOT NULL, # - # self.maxseats = maxSeats + hh['tableName'] = self.tablename + hh['maxSeats'] = self.maxseats # boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ # boardcard2 smallint, # boardcard3 smallint, @@ -141,6 +139,7 @@ db: a connected fpdb_db object""" # showdownPot INT, /* pot size at sd/street7 */ # comment TEXT, # commentTs DATETIME + handid = db.storeHand(hh) # HandsPlayers - ? ... Do we fix winnings? # Tourneys ? # TourneysPlayers diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index ad599b13..44ea2352 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -241,3 +241,27 @@ class fpdb_db: #We proabably want to cache this return result + + def storeHand(self, p): + #stores into table hands: + self.cursor.execute ("""INSERT INTO Hands + (siteHandNo, gametypeId, handStart, seats, tableName, importTime, maxSeats + ,playersVpi, playersAtStreet1, playersAtStreet2 + ,playersAtStreet3, playersAtStreet4, playersAtShowdown + ,street0Raises, street1Raises, street2Raises + ,street3Raises, street4Raises, street1Pot + ,street2Pot, street3Pot, street4Pot + ,showdownPot + ) + VALUES + (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""" + ,(p['siteHandNo'], gametype_id, p['handStart'], len(names), p['tableName'], datetime.datetime.today(), p['maxSeats'] + ,hudCache['playersVpi'], hudCache['playersAtStreet1'], hudCache['playersAtStreet2'] + ,hudCache['playersAtStreet3'], hudCache['playersAtStreet4'], hudCache['playersAtShowdown'] + ,hudCache['street0Raises'], hudCache['street1Raises'], hudCache['street2Raises'] + ,hudCache['street3Raises'], hudCache['street4Raises'], hudCache['street1Pot'] + ,hudCache['street2Pot'], hudCache['street3Pot'], hudCache['street4Pot'] + ,hudCache['showdownPot'] + ) + ) + #return getLastInsertId(backend, conn, cursor)