git35 - changed table and field names to match my naming convention to stabilise downstream-facing api.
This commit is contained in:
+1
-1
@@ -347,7 +347,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.set_title("Free Poker DB - version: alpha1+, git34")
|
||||
self.window.set_title("Free Poker DB - version: alpha1+, git35")
|
||||
self.window.set_border_width(1)
|
||||
self.window.set_size_request(950,400)
|
||||
self.window.set_resizable(True)
|
||||
|
||||
+107
-102
@@ -45,9 +45,9 @@ class fpdb_db:
|
||||
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
||||
self.cursor=self.db.cursor()
|
||||
try:
|
||||
self.cursor.execute("SELECT * FROM settings")
|
||||
self.cursor.execute("SELECT * FROM Settings")
|
||||
settings=self.cursor.fetchone()
|
||||
if settings[0]!=33:
|
||||
if settings[0]!=35:
|
||||
print "outdated database version - please recreate tables"
|
||||
except:# _mysql_exceptions.ProgrammingError:
|
||||
print "failed to read settings table - please recreate tables"
|
||||
@@ -86,30 +86,43 @@ class fpdb_db:
|
||||
|
||||
def drop_tables(self):
|
||||
"""Drops the fpdb tables from the current db"""
|
||||
self.cursor.execute("DROP TABLE IF EXISTS settings;")
|
||||
|
||||
#todo: run the below if current db is git34 or lower
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS settings;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS HudDataHoldemOmaha;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS autorates;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS board_cards;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS hands_actions;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS hands_players;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS hands;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS tourneys_players;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS tourneys;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS players;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS gametypes;")
|
||||
#self.cursor.execute("DROP TABLE IF EXISTS sites;")
|
||||
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Settings;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS HudDataHoldemOmaha;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS autorates;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS board_cards;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS hands_actions;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS hands_players;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS hands;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS tourneys_players;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS tourneys;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS players;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS gametypes;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS sites;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Autorates;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS BoardCards;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS HandsActions;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS HandsPlayers;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Hands;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS TourneysPlayers;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Tourneys;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Players;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Gametypes;")
|
||||
self.cursor.execute("DROP TABLE IF EXISTS Sites;")
|
||||
self.db.commit()
|
||||
#end def drop_tables
|
||||
|
||||
def get_backend_name(self):
|
||||
"""Returns the name of the currently used backend"""
|
||||
if self.backend==1:
|
||||
return "MySQL normal"
|
||||
elif self.backend==2:
|
||||
if self.backend==2:
|
||||
return "MySQL InnoDB"
|
||||
elif self.backend==3:
|
||||
return "PostgreSQL"
|
||||
else:
|
||||
raise fpdb_simple.FpdbError("invalid backend")
|
||||
#end def get_backend_name
|
||||
|
||||
def get_db_info(self):
|
||||
@@ -120,139 +133,131 @@ class fpdb_db:
|
||||
"""(Re-)creates the tables of the current DB"""
|
||||
self.drop_tables()
|
||||
|
||||
self.create_table("""settings (
|
||||
self.create_table("""Settings (
|
||||
version SMALLINT)""")
|
||||
|
||||
self.create_table("""sites (
|
||||
self.create_table("""Sites (
|
||||
id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
name varchar(32),
|
||||
currency char(3))""")
|
||||
|
||||
self.create_table("""gametypes (
|
||||
self.create_table("""Gametypes (
|
||||
id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
site_id SMALLINT UNSIGNED, FOREIGN KEY (site_id) REFERENCES sites(id),
|
||||
siteId SMALLINT UNSIGNED, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
type char(4),
|
||||
category varchar(9),
|
||||
limit_type char(2),
|
||||
small_blind int,
|
||||
big_blind int,
|
||||
small_bet int,
|
||||
big_bet int)""")
|
||||
limitType char(2),
|
||||
smallBlind int,
|
||||
bigBlind int,
|
||||
smallBet int,
|
||||
bigBet int)""")
|
||||
|
||||
self.create_table("""players (
|
||||
self.create_table("""Players (
|
||||
id INT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
name VARCHAR(32) CHARACTER SET utf8,
|
||||
site_id SMALLINT UNSIGNED, FOREIGN KEY (site_id) REFERENCES sites(id),
|
||||
siteId SMALLINT UNSIGNED, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
comment text,
|
||||
comment_ts DATETIME)""")
|
||||
commentTs DATETIME)""")
|
||||
|
||||
self.create_table("""autorates (
|
||||
self.create_table("""Autorates (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
player_id INT UNSIGNED, FOREIGN KEY (player_id) REFERENCES players(id),
|
||||
gametype_id SMALLINT UNSIGNED, FOREIGN KEY (gametype_id) REFERENCES gametypes(id),
|
||||
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||
description varchar(50),
|
||||
short_desc char(8),
|
||||
rating_time DATETIME,
|
||||
hand_count int)""")
|
||||
shortDesc char(8),
|
||||
ratingTime DATETIME,
|
||||
handCount int)""")
|
||||
|
||||
self.create_table("""hands (
|
||||
self.create_table("""Hands (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
site_hand_no bigint,
|
||||
gametype_id SMALLINT UNSIGNED, FOREIGN KEY (gametype_id) REFERENCES gametypes(id),
|
||||
hand_start DATETIME,
|
||||
siteHandNo bigint,
|
||||
gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||
handStart DATETIME,
|
||||
seats smallint,
|
||||
comment text,
|
||||
comment_ts DATETIME)""")
|
||||
commentTs DATETIME)""")
|
||||
|
||||
self.create_table("""board_cards (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT,
|
||||
PRIMARY KEY (id),
|
||||
hand_id BIGINT UNSIGNED,
|
||||
FOREIGN KEY (hand_id) REFERENCES hands(id),
|
||||
card1_value smallint,
|
||||
card1_suit char(1),
|
||||
card2_value smallint,
|
||||
card2_suit char(1),
|
||||
card3_value smallint,
|
||||
card3_suit char(1),
|
||||
card4_value smallint,
|
||||
card4_suit char(1),
|
||||
card5_value smallint,
|
||||
card5_suit char(1))""")
|
||||
self.create_table("""BoardCards (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
handId BIGINT UNSIGNED, FOREIGN KEY (handId) REFERENCES Hands(id),
|
||||
card1Value smallint,
|
||||
card1Suit char(1),
|
||||
card2Value smallint,
|
||||
card2Suit char(1),
|
||||
card3Value smallint,
|
||||
card3Suit char(1),
|
||||
card4Value smallint,
|
||||
card4Suit char(1),
|
||||
card5Value smallint,
|
||||
card5Suit char(1))""")
|
||||
|
||||
self.create_table("""tourneys (
|
||||
self.create_table("""Tourneys (
|
||||
id INT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
site_id SMALLINT UNSIGNED, FOREIGN KEY (site_id) REFERENCES sites(id),
|
||||
site_tourney_no BIGINT,
|
||||
siteId SMALLINT UNSIGNED, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||
siteTourneyNo BIGINT,
|
||||
buyin INT,
|
||||
fee INT,
|
||||
knockout INT,
|
||||
entries INT,
|
||||
prizepool INT,
|
||||
start_time DATETIME,
|
||||
startTime DATETIME,
|
||||
comment TEXT,
|
||||
comment_ts DATETIME)""")
|
||||
commentTs DATETIME)""")
|
||||
|
||||
self.create_table("""tourneys_players (
|
||||
self.create_table("""TourneysPlayers (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
tourney_id INT UNSIGNED, FOREIGN KEY (tourney_id) REFERENCES tourneys(id),
|
||||
player_id INT UNSIGNED, FOREIGN KEY (player_id) REFERENCES players(id),
|
||||
payin_amount INT,
|
||||
tourneyId INT UNSIGNED, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
|
||||
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
payinAmount INT,
|
||||
rank INT,
|
||||
winnings INT,
|
||||
comment TEXT,
|
||||
comment_ts DATETIME)""")
|
||||
commentTs DATETIME)""")
|
||||
|
||||
self.create_table("""hands_players (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT,
|
||||
PRIMARY KEY (id),
|
||||
hand_id BIGINT UNSIGNED,
|
||||
FOREIGN KEY (hand_id) REFERENCES hands(id),
|
||||
player_id INT UNSIGNED,
|
||||
FOREIGN KEY (player_id) REFERENCES players(id),
|
||||
player_startcash int,
|
||||
self.create_table("""HandsPlayers (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
handId BIGINT UNSIGNED, FOREIGN KEY (handId) REFERENCES Hands(id),
|
||||
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
startCash int,
|
||||
position char(1),
|
||||
ante int,
|
||||
|
||||
card1_value smallint,
|
||||
card1_suit char(1),
|
||||
card2_value smallint,
|
||||
card2_suit char(1),
|
||||
card3_value smallint,
|
||||
card3_suit char(1),
|
||||
card4_value smallint,
|
||||
card4_suit char(1),
|
||||
card5_value smallint,
|
||||
card5_suit char(1),
|
||||
card6_value smallint,
|
||||
card6_suit char(1),
|
||||
card7_value smallint,
|
||||
card7_suit char(1),
|
||||
card1Value smallint,
|
||||
card1Suit char(1),
|
||||
card2Value smallint,
|
||||
card2Suit char(1),
|
||||
card3Value smallint,
|
||||
card3Suit char(1),
|
||||
card4Value smallint,
|
||||
card4Suit char(1),
|
||||
card5Value smallint,
|
||||
card5Suit char(1),
|
||||
card6Value smallint,
|
||||
card6Suit char(1),
|
||||
card7Value smallint,
|
||||
card7Suit char(1),
|
||||
|
||||
winnings int,
|
||||
rake int,
|
||||
comment text,
|
||||
comment_ts DATETIME,
|
||||
commentTs DATETIME,
|
||||
|
||||
tourneys_players_id BIGINT UNSIGNED,
|
||||
FOREIGN KEY (tourneys_players_id) REFERENCES tourneys_players(id))""")
|
||||
tourneysPlayersId BIGINT UNSIGNED, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))""")
|
||||
|
||||
self.create_table("""hands_actions (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT,
|
||||
PRIMARY KEY (id),
|
||||
hand_player_id BIGINT UNSIGNED,
|
||||
FOREIGN KEY (hand_player_id) REFERENCES hands_players(id),
|
||||
self.create_table("""HandsActions (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
handPlayerId BIGINT UNSIGNED, FOREIGN KEY (handPlayerId) REFERENCES HandsPlayers(id),
|
||||
street SMALLINT,
|
||||
action_no SMALLINT,
|
||||
actionNo SMALLINT,
|
||||
action CHAR(5),
|
||||
amount INT,
|
||||
comment TEXT,
|
||||
comment_ts DATETIME)""")
|
||||
commentTs DATETIME)""")
|
||||
|
||||
self.create_table("""HudDataHoldemOmaha (
|
||||
id BIGINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
|
||||
gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES gametypes(id),
|
||||
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES players(id),
|
||||
gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
activeSeats SMALLINT,
|
||||
HDs INT,
|
||||
VPIP INT,
|
||||
@@ -289,9 +294,9 @@ class fpdb_db:
|
||||
thirdBarrelChance INT,
|
||||
thirdBarrelDone INT)""")
|
||||
|
||||
self.cursor.execute("INSERT INTO settings VALUES (34);")
|
||||
self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');")
|
||||
self.cursor.execute("INSERT INTO sites VALUES (DEFAULT, \"PokerStars\", 'USD');")
|
||||
self.cursor.execute("INSERT INTO Settings VALUES (35);")
|
||||
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');")
|
||||
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"PokerStars\", 'USD');")
|
||||
self.db.commit()
|
||||
print "finished recreating tables"
|
||||
#end def recreate_tables
|
||||
|
||||
@@ -94,7 +94,7 @@ def mainParser(db, cursor, site, category, hand):
|
||||
fpdb_simple.convertBlindBet(actionTypes, actionAmounts)
|
||||
fpdb_simple.checkPositions(positions)
|
||||
|
||||
cursor.execute("SELECT limit_type FROM gametypes WHERE id=%s",(gametypeID, ))
|
||||
cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, ))
|
||||
limit_type=cursor.fetchone()[0]
|
||||
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
||||
|
||||
|
||||
+53
-55
@@ -457,7 +457,7 @@ def isActionLine(line):
|
||||
|
||||
#returns whether this is a duplicate
|
||||
def isAlreadyInDB(cursor, gametypeID, siteHandNo):
|
||||
cursor.execute ("SELECT id FROM hands WHERE gametype_id=%s AND site_hand_no=%s", (gametypeID, siteHandNo))
|
||||
cursor.execute ("SELECT id FROM Hands WHERE gametypeId=%s AND siteHandNo=%s", (gametypeID, siteHandNo))
|
||||
result=cursor.fetchall()
|
||||
if (len(result)>=1):
|
||||
raise DuplicateError ("dupl")
|
||||
@@ -958,9 +958,9 @@ def recogniseGametypeID(cursor, topline, site_id, category, isTourney):#todo: th
|
||||
|
||||
#print "recogniseGametypeID small_bet/blind:",small_bet,"big bet/blind:", big_bet,"limit type:",limit_type
|
||||
if (limit_type=="fl"):
|
||||
cursor.execute ("SELECT id FROM gametypes WHERE site_id=%s AND type=%s AND category=%s AND limit_type=%s AND small_bet=%s AND big_bet=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBet=%s AND bigBet=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
else:
|
||||
cursor.execute ("SELECT id FROM gametypes WHERE site_id=%s AND type=%s AND category=%s AND limit_type=%s AND small_blind=%s AND big_blind=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBlind=%s AND bigBlind=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
result=cursor.fetchone()
|
||||
#print "tried SELECTing gametypes.id, result:",result
|
||||
|
||||
@@ -975,15 +975,15 @@ def recogniseGametypeID(cursor, topline, site_id, category, isTourney):#todo: th
|
||||
if (limit_type=="fl"):
|
||||
big_blind=small_bet #todo: read this
|
||||
small_blind=big_blind/2 #todo: read this
|
||||
cursor.execute("""INSERT INTO gametypes
|
||||
(site_id, type, category, limit_type, small_blind, big_blind, small_bet, big_bet)
|
||||
cursor.execute("""INSERT INTO Gametypes
|
||||
(siteId, type, category, limitType, smallBlind, bigBlind, smallBet, bigBet)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, type, category, limit_type, small_blind, big_blind, small_bet, big_bet))
|
||||
cursor.execute ("SELECT id FROM gametypes WHERE site_id=%s AND type=%s AND category=%s AND limit_type=%s AND small_bet=%s AND big_bet=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBet=%s AND bigBet=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
else:
|
||||
cursor.execute("""INSERT INTO gametypes
|
||||
(site_id, type, category, limit_type, small_blind, big_blind, small_bet, big_bet)
|
||||
cursor.execute("""INSERT INTO Gametypes
|
||||
(siteId, type, category, limitType, smallBlind, bigBlind, smallBet, bigBet)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, type, category, limit_type, small_bet, big_bet, 0, 0))#remember, for these bet means blind
|
||||
cursor.execute ("SELECT id FROM gametypes WHERE site_id=%s AND type=%s AND category=%s AND limit_type=%s AND small_blind=%s AND big_blind=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
cursor.execute ("SELECT id FROM Gametypes WHERE siteId=%s AND type=%s AND category=%s AND limitType=%s AND smallBlind=%s AND bigBlind=%s", (site_id, type, category, limit_type, small_bet, big_bet))
|
||||
|
||||
result=cursor.fetchone()
|
||||
#print "created new gametypes.id:",result
|
||||
@@ -995,12 +995,12 @@ def recogniseGametypeID(cursor, topline, site_id, category, isTourney):#todo: th
|
||||
def recognisePlayerIDs(cursor, names, site_id):
|
||||
result = []
|
||||
for i in range (len(names)):
|
||||
cursor.execute ("SELECT id FROM players WHERE name=%s", (names[i],))
|
||||
cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],))
|
||||
tmp=cursor.fetchall()
|
||||
if (len(tmp)==0): #new player
|
||||
cursor.execute ("INSERT INTO players (name, site_id) VALUES (%s, %s)", (names[i], site_id))
|
||||
cursor.execute ("INSERT INTO Players (name, siteId) VALUES (%s, %s)", (names[i], site_id))
|
||||
#print "Number of players rows inserted: %d" % cursor.rowcount
|
||||
cursor.execute ("SELECT id FROM players WHERE name=%s", (names[i],))
|
||||
cursor.execute ("SELECT id FROM Players WHERE name=%s", (names[i],))
|
||||
tmp=cursor.fetchall()
|
||||
#print "recognisePlayerIDs, names[i]:",names[i],"tmp:",tmp
|
||||
result.append(tmp[0][0])
|
||||
@@ -1048,9 +1048,9 @@ def recogniseSite(line):
|
||||
#returns the ID of the given site
|
||||
def recogniseSiteID(cursor, site):
|
||||
if (site=="ftp"):
|
||||
cursor.execute("SELECT id FROM sites WHERE name = ('Full Tilt Poker')")
|
||||
cursor.execute("SELECT id FROM Sites WHERE name = ('Full Tilt Poker')")
|
||||
elif (site=="ps"):
|
||||
cursor.execute("SELECT id FROM sites WHERE name = ('PokerStars')")
|
||||
cursor.execute("SELECT id FROM Sites WHERE name = ('PokerStars')")
|
||||
return cursor.fetchall()[0][0]
|
||||
#end def recogniseSiteID
|
||||
|
||||
@@ -1090,15 +1090,14 @@ def storeActions(cursor, hands_players_ids, action_types, action_amounts, action
|
||||
for i in range (len(action_types)): #iterate through streets
|
||||
for j in range (len(action_types[i])): #iterate through names
|
||||
for k in range (len(action_types[i][j])): #iterate through individual actions of that player on that street
|
||||
cursor.execute ("INSERT INTO hands_actions (hand_player_id, street, action_no, action, amount) VALUES (%s, %s, %s, %s, %s)", (hands_players_ids[j], i, actionNos[i][j][k], action_types[i][j][k], action_amounts[i][j][k]))
|
||||
cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, amount) VALUES (%s, %s, %s, %s, %s)", (hands_players_ids[j], i, actionNos[i][j][k], action_types[i][j][k], action_amounts[i][j][k]))
|
||||
#end def storeActions
|
||||
|
||||
def store_board_cards(cursor, hands_id, board_values, board_suits):
|
||||
#stores into table board_cards
|
||||
cursor.execute ("""
|
||||
INSERT INTO board_cards (hand_id, card1_value, card1_suit,
|
||||
card2_value, card2_suit, card3_value, card3_suit, card4_value, card4_suit,
|
||||
card5_value, card5_suit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
cursor.execute ("""INSERT INTO BoardCards (handId, card1Value, card1Suit,
|
||||
card2Value, card2Suit, card3Value, card3Suit, card4Value, card4Suit,
|
||||
card5Value, card5Suit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(hands_id, board_values[0], board_suits[0], board_values[1], board_suits[1],
|
||||
board_values[2], board_suits[2], board_values[3], board_suits[3],
|
||||
board_values[4], board_suits[4]))
|
||||
@@ -1106,9 +1105,9 @@ def store_board_cards(cursor, hands_id, board_values, board_suits):
|
||||
|
||||
def storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names):
|
||||
#stores into table hands
|
||||
cursor.execute ("INSERT INTO hands (site_hand_no, gametype_id, hand_start, seats) VALUES (%s, %s, %s, %s)", (site_hand_no, gametype_id, hand_start_time, len(names)))
|
||||
cursor.execute ("INSERT INTO Hands (siteHandNo, gametypeId, handStart, seats) VALUES (%s, %s, %s, %s)", (site_hand_no, gametype_id, hand_start_time, len(names)))
|
||||
#todo: find a better way of doing this...
|
||||
cursor.execute("SELECT id FROM hands WHERE site_hand_no=%s AND gametype_id=%s", (site_hand_no, gametype_id))
|
||||
cursor.execute("SELECT id FROM Hands WHERE siteHandNo=%s AND gametypeId=%s", (site_hand_no, gametype_id))
|
||||
return cursor.fetchall()[0][0]
|
||||
#end def storeHands
|
||||
|
||||
@@ -1118,22 +1117,21 @@ def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids,
|
||||
if (category=="holdem"):
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""
|
||||
INSERT INTO hands_players
|
||||
(hand_id, player_id, player_startcash, position,
|
||||
card1_value, card1_suit, card2_value, card2_suit, winnings, rake)
|
||||
INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, position,
|
||||
card1Value, card1Suit, card2Value, card2Suit, winnings, rake)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], positions[i],
|
||||
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
|
||||
winnings[i], rakes[i]))
|
||||
cursor.execute("SELECT id FROM hands_players WHERE hand_id=%s AND player_id=%s", (hands_id, player_ids[i]))
|
||||
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
|
||||
result.append(cursor.fetchall()[0][0])
|
||||
elif (category=="omahahi" or category=="omahahilo"):
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""
|
||||
INSERT INTO hands_players
|
||||
(hand_id, player_id, player_startcash, position,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
card3_value, card3_suit, card4_value, card4_suit, winnings, rake)
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, position,
|
||||
card1Value, card1Suit, card2Value, card2Suit,
|
||||
card3Value, card3Suit, card4Value, card4Suit, winnings, rake)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], positions[i],
|
||||
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
|
||||
@@ -1151,12 +1149,12 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
|
||||
#stores hands_players rows for stud/razz games. returns an array of the resulting IDs
|
||||
result=[]
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""INSERT INTO hands_players
|
||||
(hand_id, player_id, player_startcash, ante,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
card3_value, card3_suit, card4_value, card4_suit,
|
||||
card5_value, card5_suit, card6_value, card6_suit,
|
||||
card7_value, card7_suit, winnings, rake)
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, ante,
|
||||
card1Value, card1Suit, card2Value, card2Suit,
|
||||
card3Value, card3Suit, card4Value, card4Suit,
|
||||
card5Value, card5Suit, card6Value, card6Suit,
|
||||
card7Value, card7Suit, winnings, rake)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], antes[i],
|
||||
@@ -1175,20 +1173,20 @@ def store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids, start
|
||||
result=[]
|
||||
for i in range (len(player_ids)):
|
||||
if len(card_values[0])==2:
|
||||
cursor.execute ("""INSERT INTO hands_players
|
||||
(hand_id, player_id, player_startcash,position,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
winnings, rake, tourneys_players_id)
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, position,
|
||||
card1Value, card1Suit, card2Value, card2Suit,
|
||||
winnings, rake, tourneysPlayersId)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], positions[i],
|
||||
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
|
||||
winnings[i], rakes[i], tourneys_players_ids[i]))
|
||||
elif len(card_values[0])==4:
|
||||
cursor.execute ("""INSERT INTO hands_players
|
||||
(hand_id, player_id, player_startcash,position,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
card3_value, card3_suit, card4_value, card4_suit,
|
||||
winnings, rake, tourneys_players_id)
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(handId, playerId, startCash, position,
|
||||
card1Value, card1Suit, card2Value, card2Suit,
|
||||
card3Value, card3Suit, card4Value, card4Suit,
|
||||
winnings, rake, tourneysPlayersId)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
||||
(hands_id, player_ids[i], start_cashes[i], positions[i],
|
||||
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
|
||||
@@ -1196,7 +1194,7 @@ def store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids, start
|
||||
winnings[i], rakes[i], tourneys_players_ids[i]))
|
||||
else:
|
||||
raise FpdbError ("invalid card_values length:"+str(len(card_values[0])))
|
||||
cursor.execute("SELECT id FROM hands_players WHERE hand_id=%s AND player_id=%s", (hands_id, player_ids[i]))
|
||||
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
|
||||
result.append(cursor.fetchall()[0][0])
|
||||
|
||||
return result
|
||||
@@ -1207,7 +1205,7 @@ def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes,
|
||||
#stores hands_players for tourney stud/razz hands
|
||||
result=[]
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute ("""INSERT INTO hands_players
|
||||
cursor.execute ("""INSERT INTO HandsPlayers
|
||||
(hand_id, player_id, player_startcash, ante,
|
||||
card1_value, card1_suit, card2_value, card2_suit,
|
||||
card3_value, card3_suit, card4_value, card4_suit,
|
||||
@@ -1647,17 +1645,17 @@ def storeHudData(cursor, category, gametypeId, playerIds, hudImportData):
|
||||
#end def storeHudData
|
||||
|
||||
def store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time):
|
||||
cursor.execute("SELECT id FROM tourneys WHERE site_tourney_no=%s AND site_id=%s", (site_tourney_no, site_id))
|
||||
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND siteId=%s", (site_tourney_no, site_id))
|
||||
tmp=cursor.fetchone()
|
||||
#print "tried SELECTing tourneys.id, result:",tmp
|
||||
|
||||
try:
|
||||
len(tmp)
|
||||
except TypeError:
|
||||
cursor.execute("""INSERT INTO tourneys
|
||||
(site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time)
|
||||
cursor.execute("""INSERT INTO Tourneys
|
||||
(siteId, siteTourneyNo, buyin, fee, knockout, entries, prizepool, startTime)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time))
|
||||
cursor.execute("SELECT id FROM tourneys WHERE site_tourney_no=%s AND site_id=%s", (site_tourney_no, site_id))
|
||||
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND siteId=%s", (site_tourney_no, site_id))
|
||||
tmp=cursor.fetchone()
|
||||
#print "created new tourneys.id:",tmp
|
||||
return tmp[0]
|
||||
@@ -1671,18 +1669,18 @@ def store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks,
|
||||
#print "ranks:",ranks
|
||||
#print "winnings:",winnings
|
||||
for i in range (len(player_ids)):
|
||||
cursor.execute("SELECT id FROM tourneys_players WHERE tourney_id=%s AND player_id=%s", (tourney_id, player_ids[i]))
|
||||
cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId=%s", (tourney_id, player_ids[i]))
|
||||
tmp=cursor.fetchone()
|
||||
#print "tried SELECTing tourneys_players.id:",tmp
|
||||
|
||||
try:
|
||||
len(tmp)
|
||||
except TypeError:
|
||||
cursor.execute("""INSERT INTO tourneys_players
|
||||
(tourney_id, player_id, payin_amount, rank, winnings) VALUES (%s, %s, %s, %s, %s)""",
|
||||
cursor.execute("""INSERT INTO TourneysPlayers
|
||||
(tourneyId, playerId, payinAmount, rank, winnings) VALUES (%s, %s, %s, %s, %s)""",
|
||||
(tourney_id, player_ids[i], payin_amounts[i], ranks[i], winnings[i]))
|
||||
|
||||
cursor.execute("SELECT id FROM tourneys_players WHERE tourney_id=%s AND player_id=%s",
|
||||
cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId=%s",
|
||||
(tourney_id, player_ids[i]))
|
||||
tmp=cursor.fetchone()
|
||||
#print "created new tourneys_players.id:",tmp
|
||||
|
||||
@@ -177,26 +177,26 @@ class table_viewer (threading.Thread):
|
||||
#print "self.last_read_hand:",self.last_read_hand
|
||||
self.db.reconnect()
|
||||
self.cursor=self.db.cursor
|
||||
self.cursor.execute("""SELECT id FROM hands WHERE site_hand_no=%s""", (self.last_read_hand))
|
||||
self.cursor.execute("""SELECT id FROM Hands WHERE siteHandNo=%s""", (self.last_read_hand))
|
||||
hands_id_tmp=self.db.cursor.fetchone()
|
||||
#print "tmp:",hands_id_tmp
|
||||
self.hands_id=hands_id_tmp[0]
|
||||
|
||||
self.db.cursor.execute("SELECT gametype_id FROM hands WHERE id=%s", (self.hands_id, ))
|
||||
self.db.cursor.execute("SELECT gametypeId FROM Hands WHERE id=%s", (self.hands_id, ))
|
||||
self.gametype_id=self.db.cursor.fetchone()[0]
|
||||
self.cursor.execute("SELECT category FROM gametypes WHERE id=%s", (self.gametype_id, ))
|
||||
self.cursor.execute("SELECT category FROM Gametypes WHERE id=%s", (self.gametype_id, ))
|
||||
self.category=self.db.cursor.fetchone()[0]
|
||||
#print "self.gametype_id", self.gametype_id," category:", self.category, " self.hands_id:", self.hands_id
|
||||
|
||||
self.db.cursor.execute("""SELECT DISTINCT players.id FROM hands_players
|
||||
INNER JOIN players ON hands_players.player_id=players.id
|
||||
WHERE hand_id=%s""", (self.hands_id, ))
|
||||
self.db.cursor.execute("""SELECT DISTINCT Players.id FROM HandsPlayers
|
||||
INNER JOIN Players ON HandsPlayers.playerId=Players.id
|
||||
WHERE handId=%s""", (self.hands_id, ))
|
||||
self.player_ids=self.db.cursor.fetchall()
|
||||
#print "self.player_ids:",self.player_ids
|
||||
|
||||
self.db.cursor.execute("""SELECT DISTINCT players.name FROM hands_players
|
||||
INNER JOIN players ON hands_players.player_id=players.id
|
||||
WHERE hand_id=%s""", (self.hands_id, ))
|
||||
self.db.cursor.execute("""SELECT DISTINCT Players.name FROM HandsPlayers
|
||||
INNER JOIN Players ON HandsPlayers.playerId=Players.id
|
||||
WHERE handId=%s""", (self.hands_id, ))
|
||||
self.player_names=self.db.cursor.fetchall()
|
||||
#print "self.player_names:",self.player_names
|
||||
#end def table_viewer.read_names_clicked
|
||||
|
||||
Reference in New Issue
Block a user