From 341b24a2e090474375ec6a3f7f8ccb1e2b638294 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Fri, 15 Aug 2008 01:45:40 +0100 Subject: [PATCH] git35 - changed table and field names to match my naming convention to stabilise downstream-facing api. --- docs/known-bugs-and-planned-features.txt | 1 + docs/tabledesign.html | 379 +++++++++-------------- pyfpdb/fpdb.py | 2 +- pyfpdb/fpdb_db.py | 209 +++++++------ pyfpdb/fpdb_parse_logic.py | 2 +- pyfpdb/fpdb_simple.py | 108 ++++--- pyfpdb/table_viewer.py | 18 +- 7 files changed, 321 insertions(+), 398 deletions(-) diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index f2662710..83c476a2 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -3,6 +3,7 @@ Everything is subject to change and especially the order will often change. Patc alpha2 (release by 17Aug) ====== +move version into seperate file for fpdb gui and db printhand each and the 2/3 relevant printplayerflags respectively on ps-lhe-ring-successful-steal-by-cutoff.txt and ps-lhe-ring-call-3B-preflop-cb-no2b.txt auto-import seperate and improve instructions for update diff --git a/docs/tabledesign.html b/docs/tabledesign.html index 8f7b19ee..b5144967 100644 --- a/docs/tabledesign.html +++ b/docs/tabledesign.html @@ -20,7 +20,7 @@ Copyright 2008 Steffen Jobbagy-Felso
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 as published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license can be found in fdl-1.2.txt
The program itself is licensed under AGPLv3, see agpl-3.0.txt

See readme.txt for copying

-

Table settings

+

Table Settings

@@ -33,8 +33,7 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt

Field name

the git version of the database (ie. table design changes and major bugfixes require a bump)

-

Table -players

+

Table Players

@@ -52,9 +51,9 @@ players

- + - + @@ -62,14 +61,13 @@ players

- +

Field name


site_id

siteId

smallint

references sites.id

references Sites.id

comment


comment_ts

commentTs

datetime (in UTC)



-

Table -autorates

+

Table Autorates

An autorating is a computer-"recognised" label/category for a player. Examples could include "Calling Station" if a player has <20% each for aggression and folding postflop. Or "Tight-Aggressive/Aggressive" for players with <20% VPIP, >10% PFR and >40% postflop aggression.

@@ -83,14 +81,14 @@ autorates

- + - + - + - + @@ -98,23 +96,23 @@ autorates

- + - + - +


player_id

playerId

int

references players.id

references Players.id

gametype_id

gametypeId

smallint

references gametypes.id

references Gametypes.id

description

autorating description

short_desc

shortDesc

char(8)

short description e.g. for display in HUD

rating_time

ratingTime

datetime (in UTC)

timestamp of rating

hand_count

handCount

int

number of hands rating is based on


-

Table gametypes

+

Table Gametypes

@@ -127,7 +125,7 @@ autorates

- + @@ -150,7 +148,7 @@ autorates

studhl=7 Card Stud 8 orbetter

- + - + - + - + - +

Field name


site_id

siteId

smallint

references sites.id

limit_type

limitType

char(2)

nl=No Limit
cn=Cap No Limit
@@ -159,28 +157,28 @@ autorates

fl=Fixed Limit

small_blind

smallBlind

int


big_blind

bigBlind

int


small_bet

smallBet

int


big_bet

bigBet

int



-

Table sites

+

Table Sites

@@ -204,7 +202,7 @@ autorates

Field name


-

Table hands

+

Table Hands

@@ -217,17 +215,17 @@ autorates

- + - + - + @@ -242,145 +240,119 @@ autorates

- +

Field Name


site_hand_no

siteHandNo

bigint

the site's hand number

gametype_id

gametypeId

smallint

references gametypes.id

hand_start

handStart

datetime (in UTC)

start date&time of the hand


comment_ts

commentTs

datetime (in UTC)



-

Table board_cards

+

Table BoardCards

cardX -> can be 1 through 5

- - - + + + - - - + + + - - - + + + - - - + + + - - - + + +
-

Field Name

-
-

Type

-
-

Comment

-

Field Name

Type

Comment

-

id

-
-

bigint

-
-


-

-

id

bigint


-

hand_id

-
-

bigint

-
-

the site's hand number

-

handId

bigint

the site's hand number

-

cardX_value

-
-

smallint

-
-

2-10=2-10, J=11, Q=12, - K=13, A=14 (even in razz), unknown/no card=x

-

cardXValue

smallint

2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x

-

cardX_suit

-
-

char(1)

-
-

h=hearts, s=spades, - d=diamonds, c=clubs, unknown/no card=x

-

cardXSuit

char(1)

h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x

-


-

-

Table hands_players

+


+

Table HandsPlayers

cardX: can be 1 through 7, one for each card. In holdem/omaha this stores the hole cards so 3-7 or 5-7 are empty

I did not separate this into an extra table because I felt the lost space is not sufficiently large. Also the benefit for searching is far less relevant.

- - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - +

This is used in holdem/omaha only.

+ + + + + + + + + - - - - - - +

see note above table

- - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + +

Field Name

Type

Comment

id

bigint


hand_id

bigint

references hands_stud.id

player_id

int

references players.id

player_startcash

int


position

char(1)

Field Name

Type

+

Comment

id

bigint


handId

bigint

references Hands.id

playerId

int

references Players.id

startCash

int


position

char(1)

BB=B, SB=S, Button=0, Cutoff=1, etc.

-

This is used in holdem/omaha only.

ante

int

note: for cash this couldbe boolean, but in tourneys you may enter a hand with less thanthe full ante

cardX_value

smallint

ante

int

note: for cash this could be boolean, but in tourneys you may enter a hand with less than the full ante

cardXValue

smallint

2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x

-

see note above table

cardX_suit

char(1)

h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x

winnings

int

winnings in this hand (bets, antes, etc. are NOT deducted, but rake already is)

-

rake

-
-

int

-
-

rake for this player for - this hand

-
-

comment

-
-

text

-
-


-

-

cardXSuit

char(1)

h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x

-

comment_ts

-
-

datetime (in UTC)

-
-


-

-

winnings

int

winnings in this hand (bets, antes, etc. are NOT deducted, but rake already is)

-

tourneys_players_id

-
-

bigint

-
-

references - tourneys_players.id

-

rake

int

rake for this player for this hand

comment

text


commentTs

datetime (in UTC)


tourneysPlayersId

bigint

references TourneysPlayers.id

-


-

+


Table HudDataHoldemOmaha

@@ -573,7 +545,7 @@ autorates

-

Table hands_actions

+

Table HandsActions

Did separate this into an extra table because it makes SELECTing across different streets so much easier. Also the space saving will be very large.

@@ -587,9 +559,9 @@ autorates

- + - + @@ -597,7 +569,7 @@ autorates

- + @@ -619,7 +591,7 @@ autorates

- + @@ -627,53 +599,27 @@ autorates


Tournament Tables


-

Table tourneys

+

Table Tourneys


hand_player_id

handPlayerId

bigint

references hands_players.id

references HandsPlayers.id

street

street number, 0-3 (preflop, flop, turn, river) for holdem/omaha or 0-4 for razz/stud

-1 for seen showdown

action_no

actionNo

smallint

action number, this is counted from zero for each street but across all players (e.g. in a heads up where the SB calls and the BB raises and the SB calls again would have numbers 0 and 1 for blinds, 2 and 4 for call and 3 for bet)
Note that the blinds are counted as an action, so if the SB stays in the hand it'll always be action #0


comment_ts

commentTs

datetime (in UTC)


- - - + + + - - - + + + - - - + + + - - - + + + @@ -737,7 +682,7 @@ autorates

-

Field name

-
-

Type

-
-

Comment

-

Field name

Type

Comment

-

id

-
-

int

-
-


-

-

id

int


-

site_id

-
-

smallint

-
-

References sites.id

-

siteId

smallint

References Sites.id

-

site_tourney_no

-
-

bigint

-
-


-

-

siteTourneyNo

bigint


@@ -683,8 +629,7 @@ autorates

int

-

Buy-in in cents. Without - rebuy/add-on

+

Buy-in in cents. Without rebuy/add-on

-

start_time

+

startTime

datetime (in UTC)

@@ -760,7 +705,7 @@ autorates

-

comment_ts

+

commentTs

datetime (in UTC)

@@ -773,67 +718,43 @@ autorates


-

Table -tourneys_players

+

Table TourneysPlayers

- - - - - - + + + + + + + + + + + + + - - - - - - - - - - @@ -855,8 +776,7 @@ tourneys_players

signed int

@@ -873,14 +793,13 @@ tourneys_players

-

Field Name

-
-

Type

-
-

Comment

-

Field Name

Type

Comment

id

bigint


tourneyId

int

References Tourneys.id

-

id

-
-

bigint

-
-


-

-
-

tourney_id

+

playerId

int

-

References tourneys.id

+

References Players.id

-

player_id

+

payinAmount

int

-

References players.id

-
-

payin_amount

-
-

int

-
-

Buyin, fee, rebuys and - add-ons

+

Buyin, fee, rebuys and add-ons

-

Winnings (not profit) by - this player, -1 if unknown.

+

Winnings (not profit) by this player, -1 if unknown.

-

comment_ts

+

commentTs

datetime (in UTC)

-


-

+


diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index ec57bb93..e48bac7d 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -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) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index b9d5534c..cc817678 100755 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -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 diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index 617f2393..c8efc2e2 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -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) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 91f647a7..d661421b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -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 diff --git a/pyfpdb/table_viewer.py b/pyfpdb/table_viewer.py index c68341e2..47f37fce 100755 --- a/pyfpdb/table_viewer.py +++ b/pyfpdb/table_viewer.py @@ -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