[NEWIMPORT] Prep insert functions

Cleaned up storeHandsPlayers and added storeHudCacheNew

Haven't decided on the data structures to be passed in as yet so the functions only insert the bare minimum and have a list of commented out variables
This commit is contained in:
Worros 2009-10-13 17:42:02 +08:00
parent 4d04a4b1db
commit 843bd754f6

View File

@ -1420,8 +1420,7 @@ class Database:
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
q = q.replace('%s', self.sql.query['placeholder'])
print "DEBUG: p: %s" %p
print "DEBUG: gtid: %s" % p['gameTypeId']
self.cursor.execute(q, (
p['tableName'],
p['gameTypeId'],
@ -1456,101 +1455,312 @@ class Database:
#return getLastInsertId(backend, conn, cursor)
# def storeHand
def storeHandsPlayers(self, p):
#def store_hands_players_holdem_omaha(self, backend, category, hands_id, player_ids, start_cashes
# ,positions, card_values, card_suits, winnings, rakes, seatNos, hudCache):
# result=[]
#
# # postgres (and others?) needs the booleans converted to ints before saving:
# # (or we could just save them as boolean ... but then we can't sum them so easily in sql ???)
# # NO - storing booleans for now so don't need this
# #hudCacheInt = {}
# #for k,v in hudCache.iteritems():
# # if k in ('wonWhenSeenStreet1', 'wonAtSD', 'totalProfit'):
# # hudCacheInt[k] = v
# # else:
# # hudCacheInt[k] = map(lambda x: 1 if x else 0, v)
#
# try:
# inserts = []
# for i in xrange(len(player_ids)):
# card1 = Card.cardFromValueSuit(card_values[i][0], card_suits[i][0])
# card2 = Card.cardFromValueSuit(card_values[i][1], card_suits[i][1])
#
# if (category=="holdem"):
# startCards = Card.twoStartCards(card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1])
# card3 = None
# card4 = None
# elif (category=="omahahi" or category=="omahahilo"):
# startCards = Card.fourStartCards(card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1]
# ,card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3])
# card3 = Card.cardFromValueSuit(card_values[i][2], card_suits[i][2])
# card4 = Card.cardFromValueSuit(card_values[i][3], card_suits[i][3])
# else:
# raise FpdbError("invalid category")
#
# inserts.append( (
# hands_id, player_ids[i], start_cashes[i], positions[i], 1, # tourneytypeid - needed for hudcache
# card1, card2, card3, card4, startCards,
# winnings[i], rakes[i], seatNos[i], hudCache['totalProfit'][i],
# hudCache['street0VPI'][i], hudCache['street0Aggr'][i],
# hudCache['street0_3BChance'][i], hudCache['street0_3BDone'][i],
# hudCache['street1Seen'][i], hudCache['street2Seen'][i], hudCache['street3Seen'][i],
# hudCache['street4Seen'][i], hudCache['sawShowdown'][i],
# hudCache['street1Aggr'][i], hudCache['street2Aggr'][i], hudCache['street3Aggr'][i], hudCache['street4Aggr'][i],
# hudCache['otherRaisedStreet1'][i], hudCache['otherRaisedStreet2'][i],
# hudCache['otherRaisedStreet3'][i], hudCache['otherRaisedStreet4'][i],
# hudCache['foldToOtherRaisedStreet1'][i], hudCache['foldToOtherRaisedStreet2'][i],
# hudCache['foldToOtherRaisedStreet3'][i], hudCache['foldToOtherRaisedStreet4'][i],
# hudCache['wonWhenSeenStreet1'][i], hudCache['wonAtSD'][i],
# hudCache['stealAttemptChance'][i], hudCache['stealAttempted'][i], hudCache['foldBbToStealChance'][i],
# hudCache['foldedBbToSteal'][i], hudCache['foldSbToStealChance'][i], hudCache['foldedSbToSteal'][i],
# hudCache['street1CBChance'][i], hudCache['street1CBDone'][i], hudCache['street2CBChance'][i], hudCache['street2CBDone'][i],
# hudCache['street3CBChance'][i], hudCache['street3CBDone'][i], hudCache['street4CBChance'][i], hudCache['street4CBDone'][i],
# hudCache['foldToStreet1CBChance'][i], hudCache['foldToStreet1CBDone'][i],
# hudCache['foldToStreet2CBChance'][i], hudCache['foldToStreet2CBDone'][i],
# hudCache['foldToStreet3CBChance'][i], hudCache['foldToStreet3CBDone'][i],
# hudCache['foldToStreet4CBChance'][i], hudCache['foldToStreet4CBDone'][i],
# hudCache['street1CheckCallRaiseChance'][i], hudCache['street1CheckCallRaiseDone'][i],
# hudCache['street2CheckCallRaiseChance'][i], hudCache['street2CheckCallRaiseDone'][i],
# hudCache['street3CheckCallRaiseChance'][i], hudCache['street3CheckCallRaiseDone'][i],
# hudCache['street4CheckCallRaiseChance'][i], hudCache['street4CheckCallRaiseDone'][i],
# hudCache['street0Calls'][i], hudCache['street1Calls'][i], hudCache['street2Calls'][i], hudCache['street3Calls'][i], hudCache['street4Calls'][i],
# hudCache['street0Bets'][i], hudCache['street1Bets'][i], hudCache['street2Bets'][i], hudCache['street3Bets'][i], hudCache['street4Bets'][i]
# ) )
# c = self.get_cursor()
# c.executemany ("""
# INSERT INTO HandsPlayers
# (handId, playerId, startCash, position, tourneyTypeId,
# card1, card2, card3, card4, startCards, winnings, rake, seatNo, totalProfit,
# street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
# street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
# street1Aggr, street2Aggr, street3Aggr, street4Aggr,
# otherRaisedStreet1, otherRaisedStreet2, otherRaisedStreet3, otherRaisedStreet4,
# foldToOtherRaisedStreet1, foldToOtherRaisedStreet2, foldToOtherRaisedStreet3, foldToOtherRaisedStreet4,
# wonWhenSeenStreet1, wonAtSD,
# stealAttemptChance, stealAttempted, foldBbToStealChance, foldedBbToSteal, foldSbToStealChance, foldedSbToSteal,
# street1CBChance, street1CBDone, street2CBChance, street2CBDone,
# street3CBChance, street3CBDone, street4CBChance, street4CBDone,
# foldToStreet1CBChance, foldToStreet1CBDone, foldToStreet2CBChance, foldToStreet2CBDone,
# foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance, foldToStreet4CBDone,
# street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance, street2CheckCallRaiseDone,
# street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone,
# street0Calls, street1Calls, street2Calls, street3Calls, street4Calls,
# street0Bets, street1Bets, street2Bets, street3Bets, street4Bets
# )
# VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
# %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
# %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
# %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""".replace('%s', self.sql.query['placeholder'])
# ,inserts )
# result.append( self.get_last_insert_id(c) ) # wrong? not used currently
# except:
# raise FpdbError( "store_hands_players_holdem_omaha error: " + str(sys.exc_value) )
#
# return result
def storeHandsPlayers(self, hid, pid, p):
q = """INSERT INTO HandsPlayers (
handId,
playerId
)
VALUES (
%s, %s
)"""
pass
# startCash,
# position,
# tourneyTypeId,
# card1,
# card2,
# card3,
# card4,
# startCards,
# winnings,
# rake,
# seatNo,
# totalProfit,
# street0VPI,
# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
# street2Seen,
# street3Seen,
# street4Seen,
# sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# wonWhenSeenStreet1,
# wonAtSD,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# street1CBChance,
# street1CBDone,
# street2CBChance,
# street2CBDone,
# street3CBChance,
# street3CBDone,
# street4CBChance,
# street4CBDone,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone,
# street0Calls,
# street1Calls,
# street2Calls,
# street3Calls,
# street4Calls,
# street0Bets,
# street1Bets,
# street2Bets,
# street3Bets,
# street4Bets
q = q.replace('%s', self.sql.query['placeholder'])
self.cursor.execute(q, (
hid,
pid
))
# startCash,
# position,
# tourneyTypeId,
# card1,
# card2,
# card3,
# card4,
# startCards,
# winnings,
# rake,
# seatNo,
# totalProfit,
# street0VPI,
# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
# street2Seen,
# street3Seen,
# street4Seen,
# sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# wonWhenSeenStreet1,
# wonAtSD,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# street1CBChance,
# street1CBDone,
# street2CBChance,
# street2CBDone,
# street3CBChance,
# street3CBDone,
# street4CBChance,
# street4CBDone,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone,
# street0Calls,
# street1Calls,
# street2Calls,
# street3Calls,
# street4Calls,
# street0Bets,
# street1Bets,
# street2Bets,
# street3Bets,
# street4Bets
def storeHudCacheNew(self, gid, pid, hc):
q = """INSERT INTO HudCache (
gametypeId,
playerId
)
VALUES (
%s, %s
)"""
# gametypeId,
# playerId,
# activeSeats,
# position,
# tourneyTypeId,
# styleKey,
# HDs,
# street0VPI,
# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
# street2Seen,
# street3Seen,
# street4Seen,
# sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# wonWhenSeenStreet1,
# wonAtSD,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# street1CBChance,
# street1CBDone,
# street2CBChance,
# street2CBDone,
# street3CBChance,
# street3CBDone,
# street4CBChance,
# street4CBDone,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# totalProfit,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone)
q = q.replace('%s', self.sql.query['placeholder'])
self.cursor.execute(q, (
gid,
pid
))
# gametypeId,
# playerId,
# activeSeats,
# position,
# tourneyTypeId,
# styleKey,
# HDs,
# street0VPI,
# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
# street2Seen,
# street3Seen,
# street4Seen,
# sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# wonWhenSeenStreet1,
# wonAtSD,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# street1CBChance,
# street1CBDone,
# street2CBChance,
# street2CBDone,
# street3CBChance,
# street3CBDone,
# street4CBChance,
# street4CBDone,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# totalProfit,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone)
#################################