git35 - changed table and field names to match my naming convention to stabilise downstream-facing api.

This commit is contained in:
steffen123 2008-08-15 01:45:40 +01:00
parent e56a65b4c9
commit 341b24a2e0
7 changed files with 321 additions and 398 deletions

View File

@ -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

View File

@ -20,7 +20,7 @@ Copyright 2008 Steffen Jobbagy-Felso<br>
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<br>
The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
<p>See readme.txt for copying</P>
<p><B>Table settings</B></P>
<p><B>Table Settings</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD><P>Field name</P></TD>
@ -33,8 +33,7 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
<TD><P>the git version of the database (ie. table design changes and major bugfixes require a bump)</P></TD>
</TR>
</TABLE>
<p><B>Table
players</B></P>
<p><B>Table Players</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD><P>Field name</P></TD>
@ -52,9 +51,9 @@ players</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>site_id</P></TD>
<TD><P>siteId</P></TD>
<TD><P>smallint</P></TD>
<TD><P>references sites.id</P></TD>
<TD><P>references Sites.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>comment</P></TD>
@ -62,14 +61,13 @@ players</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>comment_ts</P></TD>
<TD><P>commentTs</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P><BR></P></TD>
</TR>
</TABLE>
<p><BR></P>
<p><B>Table
autorates</B></P>
<p><B>Table Autorates</B></P>
<p>An autorating is a computer-&quot;recognised&quot; label/category for a player. Examples could include &quot;Calling Station&quot; if a player has &lt;20% each for aggression and folding postflop. Or &quot;Tight-Aggressive/Aggressive&quot; for players with &lt;20% VPIP, &gt;10% PFR and &gt;40% postflop aggression.</P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
@ -83,14 +81,14 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>player_id</P></TD>
<TD><P>playerId</P></TD>
<TD><P>int</P></TD>
<TD><P>references players.id</P></TD>
<TD><P>references Players.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>gametype_id</P></TD>
<TD><P>gametypeId</P></TD>
<TD><P>smallint</P></TD>
<TD><P>references gametypes.id</P></TD>
<TD><P>references Gametypes.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>description</P></TD>
@ -98,23 +96,23 @@ autorates</B></P>
<TD><P>autorating description</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>short_desc</P></TD>
<TD><P>shortDesc</P></TD>
<TD><P>char(8)</P></TD>
<TD><P>short description e.g. for display in HUD</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>rating_time</P></TD>
<TD><P>ratingTime</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P>timestamp of rating</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>hand_count</P></TD>
<TD><P>handCount</P></TD>
<TD><P>int</P></TD>
<TD><P>number of hands rating is based on</P></TD>
</TR>
</TABLE>
<p><BR></P>
<p><B>Table gametypes</B></P>
<p><B>Table Gametypes</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD><P>Field name</P></TD>
@ -127,7 +125,7 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>site_id</P></TD>
<TD><P>siteId</P></TD>
<TD><P>smallint</P></TD>
<TD><P>references sites.id</P></TD>
</TR>
@ -150,7 +148,7 @@ autorates</B></P>
studhl=7 Card Stud 8 orbetter</p></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>limit_type</P></TD>
<TD><P>limitType</P></TD>
<TD><P>char(2)</P></TD>
<TD><p>nl=No Limit<br>
cn=Cap No Limit<br>
@ -159,28 +157,28 @@ autorates</B></P>
fl=Fixed Limit</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>small_blind</P></TD>
<TD><P>smallBlind</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>big_blind</P></TD>
<TD><P>bigBlind</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>small_bet</P></TD>
<TD><P>smallBet</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>big_bet</P></TD>
<TD><P>bigBet</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD>
</TR>
</TABLE>
<p><BR></P>
<p><B>Table sites</B></P>
<p><B>Table Sites</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD><P>Field name</P></TD>
@ -204,7 +202,7 @@ autorates</B></P>
</TR>
</TABLE>
<p><BR></P>
<p><B>Table hands</B></P>
<p><B>Table Hands</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD><P>Field Name</P></TD>
@ -217,17 +215,17 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>site_hand_no</P></TD>
<TD><P>siteHandNo</P></TD>
<TD><P>bigint</P></TD>
<TD><P>the site's hand number</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>gametype_id</P></TD>
<TD><P>gametypeId</P></TD>
<TD><P>smallint</P></TD>
<TD><P>references gametypes.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>hand_start</P></TD>
<TD><P>handStart</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P>start date&amp;time of the hand</P></TD>
</TR>
@ -242,145 +240,119 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>comment_ts</P></TD>
<TD><P>commentTs</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P><BR></P></TD>
</TR>
</TABLE>
<p><BR></P>
<p><B>Table board_cards</B></P>
<p><B>Table BoardCards</B></P>
<p>cardX -&gt; can be 1 through 5</P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD>
<P>Field Name</P>
</TD>
<TD>
<P>Type</P>
</TD>
<TD>
<P>Comment</P>
</TD>
<TD><P>Field Name</P></TD>
<TD><P>Type</P></TD>
<TD><P>Comment</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>id</P>
</TD>
<TD>
<P>bigint</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
<TD><P>id</P></TD>
<TD><P>bigint</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>hand_id</P>
</TD>
<TD>
<P>bigint</P>
</TD>
<TD>
<P>the site's hand number</P>
</TD>
<TD><P>handId</P></TD>
<TD><P>bigint</P></TD>
<TD><P>the site's hand number</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>cardX_value</P>
</TD>
<TD>
<P>smallint</P>
</TD>
<TD>
<P>2-10=2-10, J=11, Q=12,
K=13, A=14 (even in razz), unknown/no card=x</P>
</TD>
<TD><P>cardXValue</P></TD>
<TD><P>smallint</P></TD>
<TD><P>2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>cardX_suit</P>
</TD>
<TD>
<P>char(1)</P>
</TD>
<TD>
<P>h=hearts, s=spades,
d=diamonds, c=clubs, unknown/no card=x</P>
</TD>
<TD><P>cardXSuit</P></TD>
<TD><P>char(1)</P></TD>
<TD><P>h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x</P></TD>
</TR>
</TABLE>
<p><BR>
</P>
<p><B>Table hands_players</B></P>
<p><BR></P>
<p><B>Table HandsPlayers</B></P>
<p>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</P>
<p>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.</P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP><TD><P>Field Name</P></TD><TD><P>Type</P></TD><TD><P>Comment</P></TD></TR>
<TR VALIGN=TOP><TD><P>id</P></TD><TD><P>bigint</P></TD><TD><P><BR></P></TD></TR>
<TR VALIGN=TOP><TD><P>hand_id</P></TD><TD><P>bigint</P></TD><TD><P>references hands_stud.id</P></TD></TR>
<TR VALIGN=TOP><TD><P>player_id</P></TD><TD><P>int</P></TD><TD><P>references players.id</P></TD></TR>
<TR VALIGN=TOP><TD><P>player_startcash</P></TD><TD><P>int</P></TD><TD><P><BR></P></TD></TR>
<TR VALIGN=TOP><TD><P>position</P></TD><TD><P>char(1)</P></TD>
<TR VALIGN=TOP>
<TD><P>Field Name</P></TD>
<TD><P>Type</P></TD><TD>
<P>Comment</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>id</P></TD>
<TD><P>bigint</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>handId</P></TD>
<TD><P>bigint</P></TD>
<TD><P>references Hands.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>playerId</P></TD>
<TD><P>int</P></TD>
<TD><P>references Players.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>startCash</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD></TR>
<TR VALIGN=TOP>
<TD><P>position</P></TD>
<TD><P>char(1)</P></TD>
<TD><p>BB=B, SB=S, Button=0, Cutoff=1, etc.</P>
<P>This is used in holdem/omaha only.</P></TD></TR>
<TR VALIGN=TOP><TD><P>ante</P></TD><TD><P>int</P></TD><TD><P>note: for cash this couldbe boolean, but in tourneys you may enter a hand with less thanthe full ante</P></TD></TR>
<TR VALIGN=TOP><TD><P>cardX_value</P></TD><TD><P>smallint</P></TD>
<P>This is used in holdem/omaha only.</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>ante</P></TD>
<TD><P>int</P></TD>
<TD><P>note: for cash this could be boolean, but in tourneys you may enter a hand with less than the full ante</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>cardXValue</P></TD>
<TD><P>smallint</P></TD>
<TD><p>2-10=2-10, J=11, Q=12, K=13, A=14 (even in razz), unknown/no card=x</P>
<P>see note above table</P></TD></TR>
<TR VALIGN=TOP><TD><P>cardX_suit</P></TD><TD><P>char(1)</P></TD><TD><P>h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x</P></TD></TR>
<TR VALIGN=TOP><TD><P>winnings</P></TD><TD><P>int</P></TD><TD><P>winnings in this hand (bets, antes, etc. are NOT deducted, but rake already is)</P></TD></TR>
<TR VALIGN=TOP>
<TD>
<P>rake</P>
</TD>
<TD>
<P>int</P>
</TD>
<TD>
<P>rake for this player for
this hand</P>
</TD>
<P>see note above table</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>comment</P>
</TD>
<TD>
<P>text</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
<TD><P>cardXSuit</P></TD>
<TD><P>char(1)</P></TD>
<TD><P>h=hearts, s=spades, d=diamonds, c=clubs, unknown/no card=x</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>comment_ts</P>
</TD>
<TD>
<P>datetime (in UTC)</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
<TD><P>winnings</P></TD>
<TD><P>int</P></TD>
<TD><P>winnings in this hand (bets, antes, etc. are NOT deducted, but rake already is)</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>tourneys_players_id</P>
</TD>
<TD>
<P>bigint</P>
</TD>
<TD>
<P>references
tourneys_players.id</P>
</TD>
<TD><P>rake</P></TD>
<TD><P>int</P></TD>
<TD><P>rake for this player for this hand</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>comment</P></TD>
<TD><P>text</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>commentTs</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>tourneysPlayersId</P></TD>
<TD><P>bigint</P></TD>
<TD><P>references TourneysPlayers.id</P></TD>
</TR>
</TABLE>
<p><BR>
</P>
<p><BR></P>
<P><B>Table HudDataHoldemOmaha</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
@ -573,7 +545,7 @@ autorates</B></P>
</TR>
</TABLE>
<P></P>
<P><B>Table hands_actions</B></P>
<P><B>Table HandsActions</B></P>
<p>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.</P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
@ -587,9 +559,9 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>hand_player_id</P></TD>
<TD><P>handPlayerId</P></TD>
<TD><P>bigint</P></TD>
<TD><P>references hands_players.id</P></TD>
<TD><P>references HandsPlayers.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>street</P></TD>
@ -597,7 +569,7 @@ autorates</B></P>
<TD><p>street number, 0-3 (preflop, flop, turn, river) for holdem/omaha or 0-4 for razz/stud</P><P>-1 for seen showdown</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>action_no</P></TD>
<TD><P>actionNo</P></TD>
<TD><P>smallint</P></TD>
<TD><P>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)<br>
Note that the blinds are counted as an action, so if the SB stays in the hand it'll always be action #0</P></TD>
@ -619,7 +591,7 @@ autorates</B></P>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>comment_ts</P></TD>
<TD><P>commentTs</P></TD>
<TD><P>datetime (in UTC)</P></TD>
<TD><P><BR></P></TD>
</TR>
@ -627,53 +599,27 @@ autorates</B></P>
<p><BR></P>
<p><B>Tournament Tables</B></P>
<p><BR></P>
<p><B>Table tourneys</B></P>
<p><B>Table Tourneys</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD>
<P>Field name</P>
</TD>
<TD>
<P>Type</P>
</TD>
<TD>
<P>Comment</P>
</TD>
<TD><P>Field name</P></TD>
<TD><P>Type</P></TD>
<TD><P>Comment</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>id</P>
</TD>
<TD>
<P>int</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
<TD><P>id</P></TD>
<TD><P>int</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>site_id</P>
</TD>
<TD>
<P>smallint</P>
</TD>
<TD>
<P>References sites.id</P>
</TD>
<TD><P>siteId</P></TD>
<TD><P>smallint</P></TD>
<TD><P>References Sites.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>site_tourney_no</P>
</TD>
<TD>
<P>bigint</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
<TD><P>siteTourneyNo</P></TD>
<TD><P>bigint</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
@ -683,8 +629,7 @@ autorates</B></P>
<P>int</P>
</TD>
<TD>
<P>Buy-in in cents. Without
rebuy/add-on</P>
<P>Buy-in in cents. Without rebuy/add-on</P>
</TD>
</TR>
<TR VALIGN=TOP>
@ -737,7 +682,7 @@ autorates</B></P>
</TR>
<TR VALIGN=TOP>
<TD>
<P>start_time</P>
<P>startTime</P>
</TD>
<TD>
<P>datetime (in UTC)</P>
@ -760,7 +705,7 @@ autorates</B></P>
</TR>
<TR VALIGN=TOP>
<TD>
<P>comment_ts</P>
<P>commentTs</P>
</TD>
<TD>
<P>datetime (in UTC)</P>
@ -773,67 +718,43 @@ autorates</B></P>
</TABLE>
<p><BR>
</P>
<p><B>Table
tourneys_players</B></P>
<p><B>Table TourneysPlayers</B></P>
<TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0>
<TR VALIGN=TOP>
<TD>
<P>Field Name</P>
</TD>
<TD>
<P>Type</P>
</TD>
<TD>
<P>Comment</P>
</TD>
<TD><P>Field Name</P></TD>
<TD><P>Type</P></TD>
<TD><P>Comment</P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>id</P></TD>
<TD><P>bigint</P></TD>
<TD><P><BR></P></TD>
</TR>
<TR VALIGN=TOP>
<TD><P>tourneyId</P></TD>
<TD><P>int</P></TD>
<TD><P>References Tourneys.id</P></TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>id</P>
</TD>
<TD>
<P>bigint</P>
</TD>
<TD>
<P><BR>
</P>
</TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>tourney_id</P>
<P>playerId</P>
</TD>
<TD>
<P>int</P>
</TD>
<TD>
<P>References tourneys.id</P>
<P>References Players.id</P>
</TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>player_id</P>
<P>payinAmount</P>
</TD>
<TD>
<P>int</P>
</TD>
<TD>
<P>References players.id</P>
</TD>
</TR>
<TR VALIGN=TOP>
<TD>
<P>payin_amount</P>
</TD>
<TD>
<P>int</P>
</TD>
<TD>
<P>Buyin, fee, rebuys and
add-ons</P>
<P>Buyin, fee, rebuys and add-ons</P>
</TD>
</TR>
<TR VALIGN=TOP>
@ -855,8 +776,7 @@ tourneys_players</B></P>
<P>signed int</P>
</TD>
<TD>
<P>Winnings (not profit) by
this player, -1 if unknown.</P>
<P>Winnings (not profit) by this player, -1 if unknown.</P>
</TD>
</TR>
<TR VALIGN=TOP>
@ -873,14 +793,13 @@ tourneys_players</B></P>
</TR>
<TR VALIGN=TOP>
<TD>
<P>comment_ts</P>
<P>commentTs</P>
</TD>
<TD>
<P>datetime (in UTC)</P>
</TD>
<TD>
<P><BR>
</P>
<P><BR></P>
</TD>
</TR>
</TABLE>

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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