Merge branch 'master' of git://git.assembla.com/fpdb-sql
Conflicts: pyfpdb/Card.py
This commit is contained in:
commit
539fdcb070
|
@ -45,11 +45,14 @@ def twoStartCardString(card):
|
|||
else: return(s[y] + s[x] + 'o')
|
||||
|
||||
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
|
||||
Hand is stored as an int 13 * x + y where (x+2) represents rank of 1st card and
|
||||
(y+2) represents rank of second card (2=2 .. 14=Ace)
|
||||
If x > y then pair is suited, if x < y then unsuited"""
|
||||
""" Function to convert 4 value,suit pairs into a Omaha style starting hand,
|
||||
haven't decided how to encode this yet """
|
||||
# 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
|
||||
#AAKKs
|
||||
#AAKKr
|
||||
|
|
|
@ -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()
|
||||
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')
|
||||
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
|
||||
|
|
|
@ -653,6 +653,7 @@ class FpdbSQLQueries:
|
|||
activeSeats SMALLINT NOT NULL,
|
||||
position CHAR(1),
|
||||
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,
|
||||
|
||||
wonWhenSeenStreet1 FLOAT NOT NULL,
|
||||
|
@ -753,6 +754,7 @@ class FpdbSQLQueries:
|
|||
activeSeats SMALLINT,
|
||||
position CHAR(1),
|
||||
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,
|
||||
|
||||
wonWhenSeenStreet1 FLOAT NOT NULL,
|
||||
|
@ -1601,6 +1603,7 @@ class FpdbSQLQueries:
|
|||
,activeSeats
|
||||
,position
|
||||
,tourneyTypeId
|
||||
,styleKey
|
||||
,HDs
|
||||
,wonWhenSeenStreet1
|
||||
,wonAtSD
|
||||
|
@ -1675,6 +1678,7 @@ class FpdbSQLQueries:
|
|||
else 'E'
|
||||
end AS hc_position
|
||||
,hp.tourneyTypeId
|
||||
,'A000000' /* All-time cache, no key required */
|
||||
,count(1)
|
||||
,sum(wonWhenSeenStreet1)
|
||||
,sum(wonAtSD)
|
||||
|
|
|
@ -57,28 +57,55 @@ class GuiAutoImport (threading.Thread):
|
|||
self.database=settings['db-databaseName']
|
||||
|
||||
self.mainVBox=gtk.VBox(False,1)
|
||||
self.mainVBox.show()
|
||||
|
||||
self.settingsHBox = gtk.HBox(False, 0)
|
||||
self.mainVBox.pack_start(self.settingsHBox, False, True, 0)
|
||||
self.settingsHBox.show()
|
||||
hbox = gtk.HBox(True, 0) # contains 2 equal vboxes
|
||||
self.mainVBox.pack_start(hbox, False, False, 0)
|
||||
|
||||
self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:")
|
||||
self.settingsHBox.pack_start(self.intervalLabel)
|
||||
self.intervalLabel.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("Time between imports in seconds:")
|
||||
self.intervalLabel.set_alignment(xalign=1.0, yalign=0.5)
|
||||
vbox1.pack_start(self.intervalLabel, True, True, 0)
|
||||
|
||||
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.settingsHBox.pack_start(self.intervalEntry)
|
||||
self.intervalEntry.show()
|
||||
hbox.pack_start(self.intervalEntry, False, False, 0)
|
||||
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.startButton=gtk.ToggleButton("Start Autoimport")
|
||||
self.startButton = gtk.ToggleButton(" _Start Autoimport ")
|
||||
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
||||
self.mainVBox.add(self.startButton)
|
||||
self.startButton.show()
|
||||
hbox.pack_start(self.startButton, expand=False, fill=False)
|
||||
|
||||
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__
|
||||
|
@ -177,40 +204,41 @@ class GuiAutoImport (threading.Thread):
|
|||
#Create the site line given required info and setup callbacks
|
||||
#enabling and disabling sites from this interface not possible
|
||||
#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:")
|
||||
hbox.pack_start(label, False, False, 0)
|
||||
hbox1.pack_start(label, False, False, 3)
|
||||
label.show()
|
||||
|
||||
dirPath=gtk.Entry()
|
||||
dirPath.set_text(hhpath)
|
||||
hbox.pack_start(dirPath, False, True, 0)
|
||||
hbox1.pack_start(dirPath, True, True, 3)
|
||||
dirPath.show()
|
||||
|
||||
browseButton=gtk.Button("Browse...")
|
||||
browseButton.connect("clicked", self.browseClicked, [site] + [dirPath])
|
||||
hbox.pack_start(browseButton, False, False, 0)
|
||||
hbox2.pack_start(browseButton, False, False, 3)
|
||||
browseButton.show()
|
||||
|
||||
label = gtk.Label(site + " filter:")
|
||||
hbox.pack_start(label, False, False, 0)
|
||||
label = gtk.Label(' ' + site + " filter:")
|
||||
hbox2.pack_start(label, False, False, 3)
|
||||
label.show()
|
||||
|
||||
filter=gtk.Entry()
|
||||
filter.set_text(filter_name)
|
||||
hbox.pack_start(filter, False, True, 0)
|
||||
hbox2.pack_start(filter, True, True, 3)
|
||||
filter.show()
|
||||
|
||||
def addSites(self, vbox):
|
||||
def addSites(self, vbox1, vbox2):
|
||||
the_sites = self.config.get_supported_sites()
|
||||
for site in the_sites:
|
||||
pathHBox = gtk.HBox(False, 0)
|
||||
vbox.pack_start(pathHBox, False, True, 0)
|
||||
pathHBox.show()
|
||||
pathHBox1 = gtk.HBox(False, 0)
|
||||
vbox1.pack_start(pathHBox1, False, True, 0)
|
||||
pathHBox2 = gtk.HBox(False, 0)
|
||||
vbox2.pack_start(pathHBox2, False, True, 0)
|
||||
|
||||
params = self.config.get_site_parameters(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']]
|
||||
|
||||
if __name__== "__main__":
|
||||
|
|
|
@ -81,6 +81,7 @@ class HUD_main(object):
|
|||
|
||||
def kill_hud(self, event, table):
|
||||
# called by an event in the HUD, to kill this specific HUD
|
||||
if table in self.hud_dict:
|
||||
self.hud_dict[table].kill()
|
||||
self.hud_dict[table].main_window.destroy()
|
||||
self.vb.remove(self.hud_dict[table].tablehudlabel)
|
||||
|
|
148
pyfpdb/SQL.py
148
pyfpdb/SQL.py
|
@ -175,6 +175,7 @@ class Sql:
|
|||
SELECT hc.playerId AS player_id,
|
||||
hp.seatNo AS seat,
|
||||
p.name AS screen_name,
|
||||
hc.styleKey AS stylekey,
|
||||
sum(hc.HDs) AS n,
|
||||
sum(hc.street0VPI) AS vpip,
|
||||
sum(hc.street0Aggr) AS pfr,
|
||||
|
@ -237,82 +238,93 @@ class Sql:
|
|||
AND hc.gametypeId+0 = h.gametypeId+0)
|
||||
INNER JOIN Players p ON (p.id = hp.PlayerId+0)
|
||||
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
|
||||
self.query['get_stats_from_hand_aggregated'] = """
|
||||
SELECT HudCache.playerId AS player_id,
|
||||
sum(HDs) AS n,
|
||||
sum(street0VPI) AS vpip,
|
||||
sum(street0Aggr) AS pfr,
|
||||
sum(street0_3BChance) AS TB_opp_0,
|
||||
sum(street0_3BDone) AS TB_0,
|
||||
sum(street1Seen) AS saw_f,
|
||||
sum(street1Seen) AS saw_1,
|
||||
sum(street2Seen) AS saw_2,
|
||||
sum(street3Seen) AS saw_3,
|
||||
sum(street4Seen) AS saw_4,
|
||||
sum(sawShowdown) AS sd,
|
||||
sum(street1Aggr) AS aggr_1,
|
||||
sum(street2Aggr) AS aggr_2,
|
||||
sum(street3Aggr) AS aggr_3,
|
||||
sum(street4Aggr) AS aggr_4,
|
||||
sum(otherRaisedStreet1) AS was_raised_1,
|
||||
sum(otherRaisedStreet2) AS was_raised_2,
|
||||
sum(otherRaisedStreet3) AS was_raised_3,
|
||||
sum(otherRaisedStreet4) AS was_raised_4,
|
||||
sum(foldToOtherRaisedStreet1) AS f_freq_1,
|
||||
sum(foldToOtherRaisedStreet2) AS f_freq_2,
|
||||
sum(foldToOtherRaisedStreet3) AS f_freq_3,
|
||||
sum(foldToOtherRaisedStreet4) AS f_freq_4,
|
||||
sum(wonWhenSeenStreet1) AS w_w_s_1,
|
||||
sum(wonAtSD) AS wmsd,
|
||||
sum(stealAttemptChance) AS steal_opp,
|
||||
sum(stealAttempted) AS steal,
|
||||
sum(foldSbToStealChance) AS SBstolen,
|
||||
sum(foldedSbToSteal) AS SBnotDef,
|
||||
sum(foldBbToStealChance) AS BBstolen,
|
||||
sum(foldedBbToSteal) AS BBnotDef,
|
||||
sum(street1CBChance) AS CB_opp_1,
|
||||
sum(street1CBDone) AS CB_1,
|
||||
sum(street2CBChance) AS CB_opp_2,
|
||||
sum(street2CBDone) AS CB_2,
|
||||
sum(street3CBChance) AS CB_opp_3,
|
||||
sum(street3CBDone) AS CB_3,
|
||||
sum(street4CBChance) AS CB_opp_4,
|
||||
sum(street4CBDone) AS CB_4,
|
||||
sum(foldToStreet1CBChance) AS f_cb_opp_1,
|
||||
sum(foldToStreet1CBDone) AS f_cb_1,
|
||||
sum(foldToStreet2CBChance) AS f_cb_opp_2,
|
||||
sum(foldToStreet2CBDone) AS f_cb_2,
|
||||
sum(foldToStreet3CBChance) AS f_cb_opp_3,
|
||||
sum(foldToStreet3CBDone) AS f_cb_3,
|
||||
sum(foldToStreet4CBChance) AS f_cb_opp_4,
|
||||
sum(foldToStreet4CBDone) AS f_cb_4,
|
||||
sum(totalProfit) AS net,
|
||||
sum(street1CheckCallRaiseChance) AS ccr_opp_1,
|
||||
sum(street1CheckCallRaiseDone) AS ccr_1,
|
||||
sum(street2CheckCallRaiseChance) AS ccr_opp_2,
|
||||
sum(street2CheckCallRaiseDone) AS ccr_2,
|
||||
sum(street3CheckCallRaiseChance) AS ccr_opp_3,
|
||||
sum(street3CheckCallRaiseDone) AS ccr_3,
|
||||
sum(street4CheckCallRaiseChance) AS ccr_opp_4,
|
||||
sum(street4CheckCallRaiseDone) AS ccr_4
|
||||
FROM HudCache, Hands
|
||||
WHERE HudCache.PlayerId in
|
||||
(SELECT PlayerId FROM HandsPlayers
|
||||
WHERE handId = %s)
|
||||
AND Hands.id = %s
|
||||
AND HudCache.gametypeId in
|
||||
(SELECT gt1.id from Gametypes gt1, Gametypes gt2, Hands
|
||||
SELECT hc.playerId AS player_id,
|
||||
max(case when hc.gametypeId = h.gametypeId
|
||||
then hp.seatNo
|
||||
else -1
|
||||
end) AS seat,
|
||||
p.name AS screen_name,
|
||||
hc.styleKey AS stylekey,
|
||||
sum(hc.HDs) AS n,
|
||||
sum(hc.street0VPI) AS vpip,
|
||||
sum(hc.street0Aggr) AS pfr,
|
||||
sum(hc.street0_3BChance) AS TB_opp_0,
|
||||
sum(hc.street0_3BDone) AS TB_0,
|
||||
sum(hc.street1Seen) AS saw_f,
|
||||
sum(hc.street1Seen) AS saw_1,
|
||||
sum(hc.street2Seen) AS saw_2,
|
||||
sum(hc.street3Seen) AS saw_3,
|
||||
sum(hc.street4Seen) AS saw_4,
|
||||
sum(hc.sawShowdown) AS sd,
|
||||
sum(hc.street1Aggr) AS aggr_1,
|
||||
sum(hc.street2Aggr) AS aggr_2,
|
||||
sum(hc.street3Aggr) AS aggr_3,
|
||||
sum(hc.street4Aggr) AS aggr_4,
|
||||
sum(hc.otherRaisedStreet1) AS was_raised_1,
|
||||
sum(hc.otherRaisedStreet2) AS was_raised_2,
|
||||
sum(hc.otherRaisedStreet3) AS was_raised_3,
|
||||
sum(hc.otherRaisedStreet4) AS was_raised_4,
|
||||
sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
|
||||
sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
|
||||
sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
|
||||
sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
|
||||
sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
|
||||
sum(hc.wonAtSD) AS wmsd,
|
||||
sum(hc.stealAttemptChance) AS steal_opp,
|
||||
sum(hc.stealAttempted) AS steal,
|
||||
sum(hc.foldSbToStealChance) AS SBstolen,
|
||||
sum(hc.foldedSbToSteal) AS SBnotDef,
|
||||
sum(hc.foldBbToStealChance) AS BBstolen,
|
||||
sum(hc.foldedBbToSteal) AS BBnotDef,
|
||||
sum(hc.street1CBChance) AS CB_opp_1,
|
||||
sum(hc.street1CBDone) AS CB_1,
|
||||
sum(hc.street2CBChance) AS CB_opp_2,
|
||||
sum(hc.street2CBDone) AS CB_2,
|
||||
sum(hc.street3CBChance) AS CB_opp_3,
|
||||
sum(hc.street3CBDone) AS CB_3,
|
||||
sum(hc.street4CBChance) AS CB_opp_4,
|
||||
sum(hc.street4CBDone) AS CB_4,
|
||||
sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
|
||||
sum(hc.foldToStreet1CBDone) AS f_cb_1,
|
||||
sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
|
||||
sum(hc.foldToStreet2CBDone) AS f_cb_2,
|
||||
sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
|
||||
sum(hc.foldToStreet3CBDone) AS f_cb_3,
|
||||
sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
|
||||
sum(hc.foldToStreet4CBDone) AS f_cb_4,
|
||||
sum(hc.totalProfit) AS net,
|
||||
sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
|
||||
sum(hc.street1CheckCallRaiseDone) AS ccr_1,
|
||||
sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
|
||||
sum(hc.street2CheckCallRaiseDone) AS ccr_2,
|
||||
sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
|
||||
sum(hc.street3CheckCallRaiseDone) AS ccr_3,
|
||||
sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
|
||||
sum(hc.street4CheckCallRaiseDone) AS ccr_4
|
||||
FROM Hands h
|
||||
INNER JOIN HandsPlayers hp ON (hp.handId = %s)
|
||||
INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
|
||||
INNER JOIN Players p ON (p.id = hc.playerId)
|
||||
WHERE h.id = %s
|
||||
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 */
|
||||
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 = Hands.gametypeId
|
||||
AND Hands.id = %s)
|
||||
GROUP BY HudCache.PlayerId
|
||||
AND gt2.id = h.gametypeId)
|
||||
GROUP BY hc.PlayerId, hc.styleKey
|
||||
"""
|
||||
|
||||
self.query['get_players_from_hand'] = """
|
||||
|
|
|
@ -438,7 +438,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
self.tabs=[]
|
||||
self.tab_names=[]
|
||||
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.tab_box.show()
|
||||
#done tab bar
|
||||
|
|
|
@ -59,7 +59,10 @@ class fpdb_db:
|
|||
self.database=database
|
||||
if backend==self.MYSQL_INNODB:
|
||||
import MySQLdb
|
||||
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:
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
|
@ -68,15 +71,21 @@ class fpdb_db:
|
|||
# host, user and password are required
|
||||
print "host=%s user=%s pass=%s." % (host, user, password)
|
||||
if self.host and self.user and self.password:
|
||||
try:
|
||||
self.db = psycopg2.connect(host = host,
|
||||
user = user,
|
||||
password = password,
|
||||
database = database)
|
||||
except:
|
||||
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
|
||||
# For local domain-socket connections, only DB name is
|
||||
# needed, and everything else is in fact undefined and/or
|
||||
# flat out wrong
|
||||
else:
|
||||
try:
|
||||
self.db = psycopg2.connect(database = database)
|
||||
except:
|
||||
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
|
||||
else:
|
||||
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
||||
self.cursor=self.db.cursor()
|
||||
|
@ -138,7 +147,7 @@ class fpdb_db:
|
|||
|
||||
if(self.get_backend_name() == 'MySQL InnoDB'):
|
||||
#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
|
||||
self.cursor.execute(self.sql.query['list_tables'])
|
||||
|
@ -157,7 +166,7 @@ class fpdb_db:
|
|||
self.db.commit()
|
||||
#end def drop_tables
|
||||
|
||||
def drop_referencial_integrity(self):
|
||||
def drop_referential_integrity(self):
|
||||
"""Update all tables to remove foreign keys"""
|
||||
|
||||
self.cursor.execute(self.sql.query['list_tables'])
|
||||
|
@ -175,7 +184,7 @@ class fpdb_db:
|
|||
key = "`" + inner[j][0] + "_" + m.group() + "`"
|
||||
self.cursor.execute("ALTER TABLE " + inner[j][0] + " DROP FOREIGN KEY " + key)
|
||||
self.db.commit()
|
||||
#end drop_referencial_inegrity
|
||||
#end drop_referential_inegrity
|
||||
|
||||
def get_backend_name(self):
|
||||
"""Returns the name of the currently used backend"""
|
||||
|
|
|
@ -2549,7 +2549,7 @@ def storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData):
|
|||
if doInsert:
|
||||
#print "playerid before insert:",row[2]
|
||||
cursor.execute("""INSERT INTO HudCache
|
||||
(gametypeId, playerId, activeSeats, position, tourneyTypeId,
|
||||
(gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey,
|
||||
HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
|
||||
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
|
||||
street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1,
|
||||
|
@ -2561,7 +2561,7 @@ street3CBDone, street4CBChance, street4CBDone, foldToStreet1CBChance, foldToStre
|
|||
foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance,
|
||||
foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance,
|
||||
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,
|
||||
|
@ -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)""", (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:
|
||||
#print "storing updated hud data line"
|
||||
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) ):
|
||||
#print "playerid before insert:",row[2]," num = ", num
|
||||
cursor.execute("""INSERT INTO HudCache
|
||||
(gametypeId, playerId, activeSeats, position, tourneyTypeId,
|
||||
(gametypeId, playerId, activeSeats, position, tourneyTypeId, styleKey,
|
||||
HDs, street0VPI, street0Aggr, street0_3BChance, street0_3BDone,
|
||||
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
|
||||
street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1,
|
||||
|
@ -2748,7 +2755,7 @@ street3CBDone, street4CBChance, street4CBDone, foldToStreet1CBChance, foldToStre
|
|||
foldToStreet2CBChance, foldToStreet2CBDone, foldToStreet3CBChance, foldToStreet3CBDone, foldToStreet4CBChance,
|
||||
foldToStreet4CBDone, totalProfit, street1CheckCallRaiseChance, street1CheckCallRaiseDone, street2CheckCallRaiseChance,
|
||||
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,
|
||||
|
@ -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)""", (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
|
||||
# message seems to be "INSERT 0 1"
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user