Merge branch 'master' of git://git.assembla.com/fpdb-sql

Conflicts:

	pyfpdb/Card.py
This commit is contained in:
Worros 2009-05-22 09:23:10 +08:00
commit 539fdcb070
9 changed files with 205 additions and 131 deletions

View File

@ -45,11 +45,14 @@ def twoStartCardString(card):
else: return(s[y] + s[x] + 'o') else: return(s[y] + s[x] + 'o')
def fourStartCards(value1, suit1, value2, suit2, value3, suit3, value4, suit4): def fourStartCards(value1, suit1, value2, suit2, value3, suit3, value4, suit4):
""" Function to convert 4 value,suit pairs into a Omaha style starting hand e.g. AAds """ Function to convert 4 value,suit pairs into a Omaha style starting hand,
Hand is stored as an int 13 * x + y where (x+2) represents rank of 1st card and haven't decided how to encode this yet """
(y+2) represents rank of second card (2=2 .. 14=Ace)
If x > y then pair is suited, if x < y then unsuited"""
# This doesn't actually do anything yet - CG # This doesn't actually do anything yet - CG
# What combinations do we need to store? just cards: AA23? some suits as well e.g. when
# double suited ATcKTd? Lots more possible combos than holdem :-( 270K vs 1326? not sure
# Probably need to use this field as a key into some other table - sc
#AAKKds #AAKKds
#AAKKs #AAKKs
#AAKKr #AAKKr

View File

@ -191,15 +191,14 @@ class Database:
winners[row[0]] = row[1] winners[row[0]] = row[1]
return winners 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() c = self.connection.cursor()
if aggregate: if aggregate:
query = 'get_stats_from_hand_aggregated' query = 'get_stats_from_hand_aggregated'
subs = (hand, hand, hand)
else: else:
query = 'get_stats_from_hand' query = 'get_stats_from_hand'
subs = (hand, hand) subs = (hand, hand, stylekey, stylekey)
# now get the stats # now get the stats
c.execute(self.sql.query[query], subs) c.execute(self.sql.query[query], subs)
@ -218,7 +217,10 @@ class Database:
c = self.connection.cursor() c = self.connection.cursor()
c.execute(self.sql.query['get_player_id'], {'player': player_name, 'site': site}) c.execute(self.sql.query['get_player_id'], {'player': player_name, 'site': site})
row = c.fetchone() row = c.fetchone()
return row[0] if row:
return row[0]
else:
return None
if __name__=="__main__": if __name__=="__main__":
c = Configuration.Config() c = Configuration.Config()
@ -234,16 +236,17 @@ if __name__=="__main__":
print "last hand = ", h print "last hand = ", h
hero = db_connection.get_player_id(c, 'PokerStars', 'nutOmatic') 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) stat_dict = db_connection.get_stats_from_hand(h)
for p in stat_dict.keys(): for p in stat_dict.keys():
print p, " ", stat_dict[p] print p, " ", stat_dict[p]
print "nutOmatics stats:" #print "nutOmatics stats:"
stat_dict = db_connection.get_stats_from_hand(h, hero) #stat_dict = db_connection.get_stats_from_hand(h, hero)
for p in stat_dict.keys(): #for p in stat_dict.keys():
print p, " ", stat_dict[p] # print p, " ", stat_dict[p]
print "cards =", db_connection.get_cards(73525) print "cards =", db_connection.get_cards(73525)
db_connection.close_connection db_connection.close_connection

View File

@ -653,6 +653,7 @@ class FpdbSQLQueries:
activeSeats SMALLINT NOT NULL, activeSeats SMALLINT NOT NULL,
position CHAR(1), position CHAR(1),
tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
HDs INT NOT NULL, HDs INT NOT NULL,
wonWhenSeenStreet1 FLOAT NOT NULL, wonWhenSeenStreet1 FLOAT NOT NULL,
@ -753,6 +754,7 @@ class FpdbSQLQueries:
activeSeats SMALLINT, activeSeats SMALLINT,
position CHAR(1), position CHAR(1),
tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
HDs INT, HDs INT,
wonWhenSeenStreet1 FLOAT NOT NULL, wonWhenSeenStreet1 FLOAT NOT NULL,
@ -1601,6 +1603,7 @@ class FpdbSQLQueries:
,activeSeats ,activeSeats
,position ,position
,tourneyTypeId ,tourneyTypeId
,styleKey
,HDs ,HDs
,wonWhenSeenStreet1 ,wonWhenSeenStreet1
,wonAtSD ,wonAtSD
@ -1675,6 +1678,7 @@ class FpdbSQLQueries:
else 'E' else 'E'
end AS hc_position end AS hc_position
,hp.tourneyTypeId ,hp.tourneyTypeId
,'A000000' /* All-time cache, no key required */
,count(1) ,count(1)
,sum(wonWhenSeenStreet1) ,sum(wonWhenSeenStreet1)
,sum(wonAtSD) ,sum(wonAtSD)

View File

@ -57,28 +57,55 @@ class GuiAutoImport (threading.Thread):
self.database=settings['db-databaseName'] self.database=settings['db-databaseName']
self.mainVBox=gtk.VBox(False,1) self.mainVBox=gtk.VBox(False,1)
self.mainVBox.show()
self.settingsHBox = gtk.HBox(False, 0) hbox = gtk.HBox(True, 0) # contains 2 equal vboxes
self.mainVBox.pack_start(self.settingsHBox, False, True, 0) self.mainVBox.pack_start(hbox, False, False, 0)
self.settingsHBox.show()
vbox1 = gtk.VBox(True, 0)
hbox.pack_start(vbox1, True, True, 0)
vbox2 = gtk.VBox(True, 0)
hbox.pack_start(vbox2, True, True, 0)
self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:") self.intervalLabel = gtk.Label("Time between imports in seconds:")
self.settingsHBox.pack_start(self.intervalLabel) self.intervalLabel.set_alignment(xalign=1.0, yalign=0.5)
self.intervalLabel.show() vbox1.pack_start(self.intervalLabel, True, True, 0)
self.intervalEntry=gtk.Entry() hbox = gtk.HBox(False, 0)
vbox2.pack_start(hbox, True, True, 0)
self.intervalEntry = gtk.Entry()
self.intervalEntry.set_text(str(self.config.get_import_parameters().get("interval"))) self.intervalEntry.set_text(str(self.config.get_import_parameters().get("interval")))
self.settingsHBox.pack_start(self.intervalEntry) hbox.pack_start(self.intervalEntry, False, False, 0)
self.intervalEntry.show() lbl1 = gtk.Label()
hbox.pack_start(lbl1, expand=True, fill=True)
self.addSites(self.mainVBox) lbl = gtk.Label('')
vbox1.pack_start(lbl, expand=True, fill=True)
lbl = gtk.Label('')
vbox2.pack_start(lbl, expand=True, fill=True)
self.addSites(vbox1, vbox2)
hbox = gtk.HBox(False, 0)
self.mainVBox.pack_start(hbox, expand=True, padding=3)
hbox = gtk.HBox(False, 0)
self.mainVBox.pack_start(hbox, expand=False, padding=3)
lbl1 = gtk.Label()
hbox.pack_start(lbl1, expand=True, fill=False)
self.doAutoImportBool = False self.doAutoImportBool = False
self.startButton=gtk.ToggleButton("Start Autoimport") self.startButton = gtk.ToggleButton(" _Start Autoimport ")
self.startButton.connect("clicked", self.startClicked, "start clicked") self.startButton.connect("clicked", self.startClicked, "start clicked")
self.mainVBox.add(self.startButton) hbox.pack_start(self.startButton, expand=False, fill=False)
self.startButton.show()
lbl2 = gtk.Label()
hbox.pack_start(lbl2, expand=True, fill=False)
hbox = gtk.HBox(False, 0)
hbox.show()
self.mainVBox.pack_start(hbox, expand=True, padding=3)
self.mainVBox.show_all()
#end of GuiAutoImport.__init__ #end of GuiAutoImport.__init__
@ -177,40 +204,41 @@ class GuiAutoImport (threading.Thread):
#Create the site line given required info and setup callbacks #Create the site line given required info and setup callbacks
#enabling and disabling sites from this interface not possible #enabling and disabling sites from this interface not possible
#expects a box to layout the line horizontally #expects a box to layout the line horizontally
def createSiteLine(self, hbox, site, iconpath, hhpath, filter_name, active = True): def createSiteLine(self, hbox1, hbox2, site, iconpath, hhpath, filter_name, active = True):
label = gtk.Label(site + " auto-import:") label = gtk.Label(site + " auto-import:")
hbox.pack_start(label, False, False, 0) hbox1.pack_start(label, False, False, 3)
label.show() label.show()
dirPath=gtk.Entry() dirPath=gtk.Entry()
dirPath.set_text(hhpath) dirPath.set_text(hhpath)
hbox.pack_start(dirPath, False, True, 0) hbox1.pack_start(dirPath, True, True, 3)
dirPath.show() dirPath.show()
browseButton=gtk.Button("Browse...") browseButton=gtk.Button("Browse...")
browseButton.connect("clicked", self.browseClicked, [site] + [dirPath]) browseButton.connect("clicked", self.browseClicked, [site] + [dirPath])
hbox.pack_start(browseButton, False, False, 0) hbox2.pack_start(browseButton, False, False, 3)
browseButton.show() browseButton.show()
label = gtk.Label(site + " filter:") label = gtk.Label(' ' + site + " filter:")
hbox.pack_start(label, False, False, 0) hbox2.pack_start(label, False, False, 3)
label.show() label.show()
filter=gtk.Entry() filter=gtk.Entry()
filter.set_text(filter_name) filter.set_text(filter_name)
hbox.pack_start(filter, False, True, 0) hbox2.pack_start(filter, True, True, 3)
filter.show() filter.show()
def addSites(self, vbox): def addSites(self, vbox1, vbox2):
the_sites = self.config.get_supported_sites() the_sites = self.config.get_supported_sites()
for site in the_sites: for site in the_sites:
pathHBox = gtk.HBox(False, 0) pathHBox1 = gtk.HBox(False, 0)
vbox.pack_start(pathHBox, False, True, 0) vbox1.pack_start(pathHBox1, False, True, 0)
pathHBox.show() pathHBox2 = gtk.HBox(False, 0)
vbox2.pack_start(pathHBox2, False, True, 0)
params = self.config.get_site_parameters(site) params = self.config.get_site_parameters(site)
paths = self.config.get_default_paths(site) paths = self.config.get_default_paths(site)
self.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled']) self.createSiteLine(pathHBox1, pathHBox2, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']] self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
if __name__== "__main__": if __name__== "__main__":

View File

@ -81,10 +81,11 @@ class HUD_main(object):
def kill_hud(self, event, table): def kill_hud(self, event, table):
# called by an event in the HUD, to kill this specific HUD # called by an event in the HUD, to kill this specific HUD
self.hud_dict[table].kill() if table in self.hud_dict:
self.hud_dict[table].main_window.destroy() self.hud_dict[table].kill()
self.vb.remove(self.hud_dict[table].tablehudlabel) self.hud_dict[table].main_window.destroy()
del(self.hud_dict[table]) self.vb.remove(self.hud_dict[table].tablehudlabel)
del(self.hud_dict[table])
self.main_window.resize(1,1) self.main_window.resize(1,1)
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, stat_dict, cards): def create_HUD(self, new_hand_id, table, table_name, max, poker_game, stat_dict, cards):

View File

@ -175,6 +175,7 @@ class Sql:
SELECT hc.playerId AS player_id, SELECT hc.playerId AS player_id,
hp.seatNo AS seat, hp.seatNo AS seat,
p.name AS screen_name, p.name AS screen_name,
hc.styleKey AS stylekey,
sum(hc.HDs) AS n, sum(hc.HDs) AS n,
sum(hc.street0VPI) AS vpip, sum(hc.street0VPI) AS vpip,
sum(hc.street0Aggr) AS pfr, sum(hc.street0Aggr) AS pfr,
@ -237,82 +238,93 @@ class Sql:
AND hc.gametypeId+0 = h.gametypeId+0) AND hc.gametypeId+0 = h.gametypeId+0)
INNER JOIN Players p ON (p.id = hp.PlayerId+0) INNER JOIN Players p ON (p.id = hp.PlayerId+0)
WHERE h.id = %s WHERE h.id = %s
GROUP BY hc.PlayerId, hp.seatNo, p.name AND (hc.styleKey = %s or %s = 'ALL') /* styleKey should be passed in twice */
/* This allows the caller to query only a particular stylekey or all,
e.g. may want to use different values for Hero and others */
GROUP BY hc.PlayerId, hp.seatNo, p.name, hc.styleKey
""" """
# same as above except stats are aggregated for all blind/limit levels # same as above except stats are aggregated for all blind/limit levels
self.query['get_stats_from_hand_aggregated'] = """ self.query['get_stats_from_hand_aggregated'] = """
SELECT HudCache.playerId AS player_id, SELECT hc.playerId AS player_id,
sum(HDs) AS n, max(case when hc.gametypeId = h.gametypeId
sum(street0VPI) AS vpip, then hp.seatNo
sum(street0Aggr) AS pfr, else -1
sum(street0_3BChance) AS TB_opp_0, end) AS seat,
sum(street0_3BDone) AS TB_0, p.name AS screen_name,
sum(street1Seen) AS saw_f, hc.styleKey AS stylekey,
sum(street1Seen) AS saw_1, sum(hc.HDs) AS n,
sum(street2Seen) AS saw_2, sum(hc.street0VPI) AS vpip,
sum(street3Seen) AS saw_3, sum(hc.street0Aggr) AS pfr,
sum(street4Seen) AS saw_4, sum(hc.street0_3BChance) AS TB_opp_0,
sum(sawShowdown) AS sd, sum(hc.street0_3BDone) AS TB_0,
sum(street1Aggr) AS aggr_1, sum(hc.street1Seen) AS saw_f,
sum(street2Aggr) AS aggr_2, sum(hc.street1Seen) AS saw_1,
sum(street3Aggr) AS aggr_3, sum(hc.street2Seen) AS saw_2,
sum(street4Aggr) AS aggr_4, sum(hc.street3Seen) AS saw_3,
sum(otherRaisedStreet1) AS was_raised_1, sum(hc.street4Seen) AS saw_4,
sum(otherRaisedStreet2) AS was_raised_2, sum(hc.sawShowdown) AS sd,
sum(otherRaisedStreet3) AS was_raised_3, sum(hc.street1Aggr) AS aggr_1,
sum(otherRaisedStreet4) AS was_raised_4, sum(hc.street2Aggr) AS aggr_2,
sum(foldToOtherRaisedStreet1) AS f_freq_1, sum(hc.street3Aggr) AS aggr_3,
sum(foldToOtherRaisedStreet2) AS f_freq_2, sum(hc.street4Aggr) AS aggr_4,
sum(foldToOtherRaisedStreet3) AS f_freq_3, sum(hc.otherRaisedStreet1) AS was_raised_1,
sum(foldToOtherRaisedStreet4) AS f_freq_4, sum(hc.otherRaisedStreet2) AS was_raised_2,
sum(wonWhenSeenStreet1) AS w_w_s_1, sum(hc.otherRaisedStreet3) AS was_raised_3,
sum(wonAtSD) AS wmsd, sum(hc.otherRaisedStreet4) AS was_raised_4,
sum(stealAttemptChance) AS steal_opp, sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
sum(stealAttempted) AS steal, sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
sum(foldSbToStealChance) AS SBstolen, sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
sum(foldedSbToSteal) AS SBnotDef, sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
sum(foldBbToStealChance) AS BBstolen, sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
sum(foldedBbToSteal) AS BBnotDef, sum(hc.wonAtSD) AS wmsd,
sum(street1CBChance) AS CB_opp_1, sum(hc.stealAttemptChance) AS steal_opp,
sum(street1CBDone) AS CB_1, sum(hc.stealAttempted) AS steal,
sum(street2CBChance) AS CB_opp_2, sum(hc.foldSbToStealChance) AS SBstolen,
sum(street2CBDone) AS CB_2, sum(hc.foldedSbToSteal) AS SBnotDef,
sum(street3CBChance) AS CB_opp_3, sum(hc.foldBbToStealChance) AS BBstolen,
sum(street3CBDone) AS CB_3, sum(hc.foldedBbToSteal) AS BBnotDef,
sum(street4CBChance) AS CB_opp_4, sum(hc.street1CBChance) AS CB_opp_1,
sum(street4CBDone) AS CB_4, sum(hc.street1CBDone) AS CB_1,
sum(foldToStreet1CBChance) AS f_cb_opp_1, sum(hc.street2CBChance) AS CB_opp_2,
sum(foldToStreet1CBDone) AS f_cb_1, sum(hc.street2CBDone) AS CB_2,
sum(foldToStreet2CBChance) AS f_cb_opp_2, sum(hc.street3CBChance) AS CB_opp_3,
sum(foldToStreet2CBDone) AS f_cb_2, sum(hc.street3CBDone) AS CB_3,
sum(foldToStreet3CBChance) AS f_cb_opp_3, sum(hc.street4CBChance) AS CB_opp_4,
sum(foldToStreet3CBDone) AS f_cb_3, sum(hc.street4CBDone) AS CB_4,
sum(foldToStreet4CBChance) AS f_cb_opp_4, sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
sum(foldToStreet4CBDone) AS f_cb_4, sum(hc.foldToStreet1CBDone) AS f_cb_1,
sum(totalProfit) AS net, sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
sum(street1CheckCallRaiseChance) AS ccr_opp_1, sum(hc.foldToStreet2CBDone) AS f_cb_2,
sum(street1CheckCallRaiseDone) AS ccr_1, sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
sum(street2CheckCallRaiseChance) AS ccr_opp_2, sum(hc.foldToStreet3CBDone) AS f_cb_3,
sum(street2CheckCallRaiseDone) AS ccr_2, sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
sum(street3CheckCallRaiseChance) AS ccr_opp_3, sum(hc.foldToStreet4CBDone) AS f_cb_4,
sum(street3CheckCallRaiseDone) AS ccr_3, sum(hc.totalProfit) AS net,
sum(street4CheckCallRaiseChance) AS ccr_opp_4, sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
sum(street4CheckCallRaiseDone) AS ccr_4 sum(hc.street1CheckCallRaiseDone) AS ccr_1,
FROM HudCache, Hands sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
WHERE HudCache.PlayerId in sum(hc.street2CheckCallRaiseDone) AS ccr_2,
(SELECT PlayerId FROM HandsPlayers sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
WHERE handId = %s) sum(hc.street3CheckCallRaiseDone) AS ccr_3,
AND Hands.id = %s sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
AND HudCache.gametypeId in sum(hc.street4CheckCallRaiseDone) AS ccr_4
(SELECT gt1.id from Gametypes gt1, Gametypes gt2, Hands FROM Hands h
WHERE gt1.siteid = gt2.siteid INNER JOIN HandsPlayers hp ON (hp.handId = %s)
AND gt1.type = gt2.type INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
AND gt1.category = gt2.category INNER JOIN Players p ON (p.id = hc.playerId)
AND gt1.limittype = gt2.limittype WHERE h.id = %s
AND gt2.id = Hands.gametypeId AND (hc.styleKey = %s or %s = 'ALL') /* styleKey should be passed in twice */
AND Hands.id = %s) /* This allows the caller to query only a particular stylekey or all,
GROUP BY HudCache.PlayerId e.g. may want to use different values for Hero and others */
AND hc.gametypeId+0 in
(SELECT gt1.id from Gametypes gt1, Gametypes gt2
WHERE gt1.siteid = gt2.siteid
AND gt1.type = gt2.type
AND gt1.category = gt2.category
AND gt1.limittype = gt2.limittype
AND gt2.id = h.gametypeId)
GROUP BY hc.PlayerId, hc.styleKey
""" """
self.query['get_players_from_hand'] = """ self.query['get_players_from_hand'] = """

View File

@ -438,7 +438,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
self.tabs=[] self.tabs=[]
self.tab_names=[] self.tab_names=[]
self.tab_buttons=[] self.tab_buttons=[]
self.tab_box = gtk.HBox(False,1) self.tab_box = gtk.HBox(True,1)
self.main_vbox.pack_start(self.tab_box, False, True, 0) self.main_vbox.pack_start(self.tab_box, False, True, 0)
self.tab_box.show() self.tab_box.show()
#done tab bar #done tab bar

View File

@ -59,7 +59,10 @@ class fpdb_db:
self.database=database self.database=database
if backend==self.MYSQL_INNODB: if backend==self.MYSQL_INNODB:
import MySQLdb import MySQLdb
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True) try:
self.db = MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True)
except:
raise fpdb_simple.FpdbError("MySQL connection failed")
elif backend==self.PGSQL: elif backend==self.PGSQL:
import psycopg2 import psycopg2
import psycopg2.extensions import psycopg2.extensions
@ -68,15 +71,21 @@ class fpdb_db:
# host, user and password are required # host, user and password are required
print "host=%s user=%s pass=%s." % (host, user, password) print "host=%s user=%s pass=%s." % (host, user, password)
if self.host and self.user and self.password: if self.host and self.user and self.password:
self.db = psycopg2.connect(host = host, try:
user = user, self.db = psycopg2.connect(host = host,
password = password, user = user,
database = database) password = password,
database = database)
except:
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
# For local domain-socket connections, only DB name is # For local domain-socket connections, only DB name is
# needed, and everything else is in fact undefined and/or # needed, and everything else is in fact undefined and/or
# flat out wrong # flat out wrong
else: else:
self.db = psycopg2.connect(database = database) try:
self.db = psycopg2.connect(database = database)
except:
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
else: else:
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend) raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
self.cursor=self.db.cursor() self.cursor=self.db.cursor()
@ -138,7 +147,7 @@ class fpdb_db:
if(self.get_backend_name() == 'MySQL InnoDB'): if(self.get_backend_name() == 'MySQL InnoDB'):
#Databases with FOREIGN KEY support need this switched of before you can drop tables #Databases with FOREIGN KEY support need this switched of before you can drop tables
self.drop_referencial_integrity() self.drop_referential_integrity()
# Query the DB to see what tables exist # Query the DB to see what tables exist
self.cursor.execute(self.sql.query['list_tables']) self.cursor.execute(self.sql.query['list_tables'])
@ -157,7 +166,7 @@ class fpdb_db:
self.db.commit() self.db.commit()
#end def drop_tables #end def drop_tables
def drop_referencial_integrity(self): def drop_referential_integrity(self):
"""Update all tables to remove foreign keys""" """Update all tables to remove foreign keys"""
self.cursor.execute(self.sql.query['list_tables']) self.cursor.execute(self.sql.query['list_tables'])
@ -175,7 +184,7 @@ class fpdb_db:
key = "`" + inner[j][0] + "_" + m.group() + "`" key = "`" + inner[j][0] + "_" + m.group() + "`"
self.cursor.execute("ALTER TABLE " + inner[j][0] + " DROP FOREIGN KEY " + key) self.cursor.execute("ALTER TABLE " + inner[j][0] + " DROP FOREIGN KEY " + key)
self.db.commit() self.db.commit()
#end drop_referencial_inegrity #end drop_referential_inegrity
def get_backend_name(self): def get_backend_name(self):
"""Returns the name of the currently used backend""" """Returns the name of the currently used backend"""

View File

@ -2549,7 +2549,7 @@ def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData):
if doInsert: if doInsert:
#print "playerid before insert:",row[2] #print "playerid before insert:",row[2]
cursor.execute("""INSERT INTO HudCache cursor.execute("""INSERT INTO HudCache
(gametypeId, playerId, activeSeats, position, tourneyTypeId, (gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey,
HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone, HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown, street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1, street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1,
@ -2561,7 +2561,7 @@ street3CBDone, street4CBChance, street4CBDone, foldToStreet1CBChance, foldToStre
foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance, foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance,
foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance, foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance,
street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone) street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone)
VALUES (%s, %s, %s, %s, %s, 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,
@ -2572,7 +2572,14 @@ 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)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[22], row[23], row[24], row[25], row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40], row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50], row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60])) %s, %s, %s, %s, %s)"""
# hard-code styleKey as 'A000000' (all-time cache, no key) for now
, (row[1], row[2], row[3], row[4], row[5], 'A000000', row[6], row[7], row[8], row[9], row[10]
,row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20]
,row[21], row[22], row[23], row[24], row[25], row[26], row[27], row[28], row[29], row[30]
,row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40]
,row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50]
,row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60]))
else: else:
#print "storing updated hud data line" #print "storing updated hud data line"
cursor.execute("""UPDATE HudCache cursor.execute("""UPDATE HudCache
@ -2736,7 +2743,7 @@ AND tourneyTypeId+0=%s""", (row[6], row[7], row[8], row[9], row[10],
or (backend == MYSQL_INNODB and num == 0) ): or (backend == MYSQL_INNODB and num == 0) ):
#print "playerid before insert:",row[2]," num = ", num #print "playerid before insert:",row[2]," num = ", num
cursor.execute("""INSERT INTO HudCache cursor.execute("""INSERT INTO HudCache
(gametypeId, playerId, activeSeats, position, tourneyTypeId, (gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey,
HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone, HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown, street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1, street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1,
@ -2748,7 +2755,7 @@ street3CBDone, street4CBChance, street4CBDone, foldToStreet1CBChance, foldToStre
foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance, foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance,
foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance, foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance,
street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone) street2CheckCallRaiseDone, street3CheckCallRaiseChance, street3CheckCallRaiseDone, street4CheckCallRaiseChance, street4CheckCallRaiseDone)
VALUES (%s, %s, %s, %s, %s, 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,
@ -2759,7 +2766,14 @@ 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)""", (row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20], row[21], row[22], row[23], row[24], row[25], row[26], row[27], row[28], row[29], row[30], row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40], row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50], row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60])) %s, %s, %s, %s, %s)"""
# hard-code styleKey as 'A000000' (all-time cache, no key) for now
, (row[1], row[2], row[3], row[4], row[5], 'A000000', row[6], row[7], row[8], row[9], row[10]
,row[11], row[12], row[13], row[14], row[15], row[16], row[17], row[18], row[19], row[20]
,row[21], row[22], row[23], row[24], row[25], row[26], row[27], row[28], row[29], row[30]
,row[31], row[32], row[33], row[34], row[35], row[36], row[37], row[38], row[39], row[40]
,row[41], row[42], row[43], row[44], row[45], row[46], row[47], row[48], row[49], row[50]
,row[51], row[52], row[53], row[54], row[55], row[56], row[57], row[58], row[59], row[60]) )
#print "hopefully inserted hud data line: ", cursor.statusmessage #print "hopefully inserted hud data line: ", cursor.statusmessage
# message seems to be "INSERT 0 1" # message seems to be "INSERT 0 1"
else: else: