diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py
index 1f47b61b..01f1c74c 100755
--- a/pyfpdb/Configuration.py
+++ b/pyfpdb/Configuration.py
@@ -236,11 +236,10 @@ class Database:
self.db_server = node.getAttribute("db_server").lower()
self.db_ip = node.getAttribute("db_ip")
self.db_user = node.getAttribute("db_user")
- self.db_type = node.getAttribute("db_type")
self.db_pass = node.getAttribute("db_pass")
self.db_selected = string_to_bool(node.getAttribute("default"), default=False)
- log.debug("Database db_name:'%(name)s' db_server:'%(server)s' db_ip:'%(ip)s' db_user:'%(user)s' db_type:'%(type)s' db_pass (not logged) selected:'%(sel)s'" \
- % { 'name':self.db_name, 'server':self.db_server, 'ip':self.db_ip, 'user':self.db_user, 'type':self.db_type, 'sel':self.db_selected} )
+ log.debug("Database db_name:'%(name)s' db_server:'%(server)s' db_ip:'%(ip)s' db_user:'%(user)s' db_pass (not logged) selected:'%(sel)s'" \
+ % { 'name':self.db_name, 'server':self.db_server, 'ip':self.db_ip, 'user':self.db_user, 'sel':self.db_selected} )
def __str__(self):
temp = 'Database = ' + self.db_name + '\n'
@@ -627,9 +626,6 @@ class Config:
try: db['db-server'] = self.supported_databases[name].db_server
except: pass
- try: db['db-type'] = self.supported_databases[name].db_type
- except: pass
-
if self.supported_databases[name].db_server== DATABASE_TYPE_MYSQL:
db['db-backend'] = 2
elif self.supported_databases[name].db_server== DATABASE_TYPE_POSTGRESQL:
@@ -641,20 +637,18 @@ class Config:
return db
def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None,
- db_pass = None, db_server = None, db_type = None):
+ db_pass = None, db_server = None):
db_node = self.get_db_node(db_name)
if db_node != None:
if db_ip != None: db_node.setAttribute("db_ip", db_ip)
if db_user != None: db_node.setAttribute("db_user", db_user)
if db_pass != None: db_node.setAttribute("db_pass", db_pass)
if db_server != None: db_node.setAttribute("db_server", db_server)
- if db_type != None: db_node.setAttribute("db_type", db_type)
if self.supported_databases.has_key(db_name):
if db_ip != None: self.supported_databases[db_name].dp_ip = db_ip
if db_user != None: self.supported_databases[db_name].dp_user = db_user
if db_pass != None: self.supported_databases[db_name].dp_pass = db_pass
if db_server != None: self.supported_databases[db_name].dp_server = db_server
- if db_type != None: self.supported_databases[db_name].dp_type = db_type
return
def getDefaultSite(self):
diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py
index 1533c05c..c9051c9c 100755
--- a/pyfpdb/Database.py
+++ b/pyfpdb/Database.py
@@ -205,7 +205,7 @@ class Database:
# where possible avoid creating new SQL instance by using the global one passed in
if sql is None:
- self.sql = SQL.Sql(type = self.type, db_server = self.db_server)
+ self.sql = SQL.Sql(db_server = self.db_server)
else:
self.sql = sql
@@ -249,7 +249,6 @@ class Database:
db_params = c.get_db_parameters()
self.import_options = c.get_import_parameters()
- self.type = db_params['db-type']
self.backend = db_params['db-backend']
self.db_server = db_params['db-server']
self.database = db_params['db-databaseName']
diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example
index 34a8f16d..e8c8f626 100644
--- a/pyfpdb/HUD_config.xml.example
+++ b/pyfpdb/HUD_config.xml.example
@@ -570,8 +570,8 @@ Left-Drag to Move"
-
-
+
+
diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py
index 3c25963f..82979e76 100644
--- a/pyfpdb/SQL.py
+++ b/pyfpdb/SQL.py
@@ -33,312 +33,295 @@ import re
class Sql:
- def __init__(self, game = 'holdem', type = 'fpdb', db_server = 'mysql'):
+ def __init__(self, game = 'holdem', db_server = 'mysql'):
self.query = {}
###############################################################################3
# Support for the Free Poker DataBase = fpdb http://fpdb.sourceforge.net/
#
- if type == 'fpdb':
- ################################
- # List tables
- ################################
- if db_server == 'mysql':
- self.query['list_tables'] = """SHOW TABLES"""
- elif db_server == 'postgresql':
- self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"""
- elif db_server == 'sqlite':
- self.query['list_tables'] = """SELECT name FROM sqlite_master
- WHERE type='table'
- ORDER BY name;"""
+ ################################
+ # List tables
+ ################################
+ if db_server == 'mysql':
+ self.query['list_tables'] = """SHOW TABLES"""
+ elif db_server == 'postgresql':
+ self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"""
+ elif db_server == 'sqlite':
+ self.query['list_tables'] = """SELECT name FROM sqlite_master
+ WHERE type='table'
+ ORDER BY name;"""
- ##################################################################
- # Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax
- ##################################################################
+ ##################################################################
+ # Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax
+ ##################################################################
- self.query['drop_table'] = """DROP TABLE IF EXISTS """
+ self.query['drop_table'] = """DROP TABLE IF EXISTS """
- ################################
- # Create Settings
- ################################
- if db_server == 'mysql':
- self.query['createSettingsTable'] = """CREATE TABLE Settings (
- version SMALLINT NOT NULL)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT NOT NULL)"""
+ ################################
+ # Create Settings
+ ################################
+ if db_server == 'mysql':
+ self.query['createSettingsTable'] = """CREATE TABLE Settings (
+ version SMALLINT NOT NULL)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT NOT NULL)"""
- elif db_server == 'sqlite':
- self.query['createSettingsTable'] = """CREATE TABLE Settings
- (version INTEGER NOT NULL) """
+ elif db_server == 'sqlite':
+ self.query['createSettingsTable'] = """CREATE TABLE Settings
+ (version INTEGER NOT NULL) """
- ################################
- # Create Sites
- ################################
+ ################################
+ # Create Sites
+ ################################
- if db_server == 'mysql':
- self.query['createSitesTable'] = """CREATE TABLE Sites (
- id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- name varchar(32) NOT NULL,
- currency char(3) NOT NULL)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createSitesTable'] = """CREATE TABLE Sites (
- id SERIAL, PRIMARY KEY (id),
- name varchar(32),
- currency char(3))"""
- elif db_server == 'sqlite':
- self.query['createSitesTable'] = """CREATE TABLE Sites (
+ if db_server == 'mysql':
+ self.query['createSitesTable'] = """CREATE TABLE Sites (
+ id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ name varchar(32) NOT NULL,
+ currency char(3) NOT NULL)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createSitesTable'] = """CREATE TABLE Sites (
+ id SERIAL, PRIMARY KEY (id),
+ name varchar(32),
+ currency char(3))"""
+ elif db_server == 'sqlite':
+ self.query['createSitesTable'] = """CREATE TABLE Sites (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL,
+ currency TEXT NOT NULL)"""
+
+
+ ################################
+ # Create Gametypes
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
+ id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
+ type char(4) NOT NULL,
+ base char(4) NOT NULL,
+ category varchar(9) NOT NULL,
+ limitType char(2) NOT NULL,
+ hiLo char(1) NOT NULL,
+ smallBlind int,
+ bigBlind int,
+ smallBet int NOT NULL,
+ bigBet int NOT NULL)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
+ id SERIAL, PRIMARY KEY (id),
+ siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
+ type char(4),
+ base char(4),
+ category varchar(9),
+ limitType char(2),
+ hiLo char(1),
+ smallBlind int,
+ bigBlind int,
+ smallBet int,
+ bigBet int)"""
+ elif db_server == 'sqlite':
+ self.query['createGametypesTable'] = """CREATE TABLE GameTypes (
+ id INTEGER PRIMARY KEY,
+ siteId INTEGER,
+ type TEXT,
+ base TEXT,
+ category TEXT,
+ limitType TEXT,
+ hiLo TEXT,
+ smallBlind INTEGER,
+ bigBlind INTEGER,
+ smallBet INTEGER,
+ bigBet INTEGER,
+ FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
+
+
+ ################################
+ # Create Players
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createPlayersTable'] = """CREATE TABLE Players (
+ id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ name VARCHAR(32) CHARACTER SET utf8 NOT NULL,
+ siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
+ comment text,
+ commentTs DATETIME)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createPlayersTable'] = """CREATE TABLE Players (
+ id SERIAL, PRIMARY KEY (id),
+ name VARCHAR(32),
+ siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
+ comment text,
+ commentTs timestamp without time zone)"""
+ elif db_server == 'sqlite':
+ self.query['createPlayersTable'] = """CREATE TABLE Players (
+ id INTEGER PRIMARY KEY,
+ name TEXT,
+ siteId INTEGER,
+ comment TEXT,
+ commentTs REAL,
+ FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
+
+
+ ################################
+ # Create Autorates
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
+ gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ description varchar(50) NOT NULL,
+ shortDesc char(8) NOT NULL,
+ ratingTime DATETIME NOT NULL,
+ handCount int NOT NULL)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
+ id BIGSERIAL, PRIMARY KEY (id),
+ playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
+ gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ description varchar(50),
+ shortDesc char(8),
+ ratingTime timestamp without time zone,
+ handCount int)"""
+ elif db_server == 'sqlite':
+ self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
id INTEGER PRIMARY KEY,
- name TEXT NOT NULL,
- currency TEXT NOT NULL)"""
+ playerId INT,
+ gametypeId INT,
+ description TEXT,
+ shortDesc TEXT,
+ ratingTime REAL,
+ handCount int)"""
- ################################
- # Create Gametypes
- ################################
+ ################################
+ # Create Hands
+ ################################
- if db_server == 'mysql':
- self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
+ if db_server == 'mysql':
+ self.query['createHandsTable'] = """CREATE TABLE Hands (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ tableName VARCHAR(20) NOT NULL,
+ siteHandNo BIGINT NOT NULL,
+ gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ handStart DATETIME NOT NULL,
+ importTime DATETIME NOT NULL,
+ seats TINYINT NOT NULL,
+ maxSeats TINYINT NOT NULL,
+ boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ boardcard2 smallint,
+ boardcard3 smallint,
+ boardcard4 smallint,
+ boardcard5 smallint,
+ texture smallint,
+ playersVpi SMALLINT NOT NULL, /* num of players vpi */
+ playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
+ playersAtStreet2 SMALLINT NOT NULL,
+ playersAtStreet3 SMALLINT NOT NULL,
+ playersAtStreet4 SMALLINT NOT NULL,
+ playersAtShowdown SMALLINT NOT NULL,
+ street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
+ street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */
+ street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */
+ street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */
+ street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
+ street1Pot INT, /* pot size at flop/street4 */
+ street2Pot INT, /* pot size at turn/street5 */
+ street3Pot INT, /* pot size at river/street6 */
+ street4Pot INT, /* pot size at sd/street7 */
+ showdownPot INT, /* pot size at sd/street7 */
+ comment TEXT,
+ commentTs DATETIME)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createHandsTable'] = """CREATE TABLE Hands (
+ id BIGSERIAL, PRIMARY KEY (id),
+ tableName VARCHAR(20) NOT NULL,
+ siteHandNo BIGINT NOT NULL,
+ gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ handStart timestamp without time zone NOT NULL,
+ importTime timestamp without time zone NOT NULL,
+ seats SMALLINT NOT NULL,
+ maxSeats SMALLINT NOT NULL,
+ boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ boardcard2 smallint,
+ boardcard3 smallint,
+ boardcard4 smallint,
+ boardcard5 smallint,
+ texture smallint,
+ playersVpi SMALLINT NOT NULL, /* num of players vpi */
+ playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
+ playersAtStreet2 SMALLINT NOT NULL,
+ playersAtStreet3 SMALLINT NOT NULL,
+ playersAtStreet4 SMALLINT NOT NULL,
+ playersAtShowdown SMALLINT NOT NULL,
+ street0Raises SMALLINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
+ street1Raises SMALLINT NOT NULL, /* num small bets paid to see turn/street5 */
+ street2Raises SMALLINT NOT NULL, /* num big bets paid to see river/street6 */
+ street3Raises SMALLINT NOT NULL, /* num big bets paid to see sd/street7 */
+ street4Raises SMALLINT NOT NULL, /* num big bets paid to see showdown */
+ street1Pot INT, /* pot size at flop/street4 */
+ street2Pot INT, /* pot size at turn/street5 */
+ street3Pot INT, /* pot size at river/street6 */
+ street4Pot INT, /* pot size at sd/street7 */
+ showdownPot INT, /* pot size at sd/street7 */
+ comment TEXT,
+ commentTs timestamp without time zone)"""
+ elif db_server == 'sqlite':
+ self.query['createHandsTable'] = """CREATE TABLE Hands (
+ id INTEGER PRIMARY KEY,
+ tableName TEXT(20) NOT NULL,
+ siteHandNo INT NOT NULL,
+ gametypeId INT NOT NULL,
+ handStart REAL NOT NULL,
+ importTime REAL NOT NULL,
+ seats INT NOT NULL,
+ maxSeats INT NOT NULL,
+ boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ boardcard2 INT,
+ boardcard3 INT,
+ boardcard4 INT,
+ boardcard5 INT,
+ texture INT,
+ playersVpi INT NOT NULL, /* num of players vpi */
+ playersAtStreet1 INT NOT NULL, /* num of players seeing flop/street4 */
+ playersAtStreet2 INT NOT NULL,
+ playersAtStreet3 INT NOT NULL,
+ playersAtStreet4 INT NOT NULL,
+ playersAtShowdown INT NOT NULL,
+ street0Raises INT NOT NULL, /* num small bets paid to see flop/street4, including blind */
+ street1Raises INT NOT NULL, /* num small bets paid to see turn/street5 */
+ street2Raises INT NOT NULL, /* num big bets paid to see river/street6 */
+ street3Raises INT NOT NULL, /* num big bets paid to see sd/street7 */
+ street4Raises INT NOT NULL, /* num big bets paid to see showdown */
+ street1Pot INT, /* pot size at flop/street4 */
+ street2Pot INT, /* pot size at turn/street5 */
+ street3Pot INT, /* pot size at river/street6 */
+ street4Pot INT, /* pot size at sd/street7 */
+ showdownPot INT, /* pot size at sd/street7 */
+ comment TEXT,
+ commentTs REAL)"""
+
+
+ ################################
+ # Create TourneyTypes
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
- type char(4) NOT NULL,
- base char(4) NOT NULL,
- category varchar(9) NOT NULL,
- limitType char(2) NOT NULL,
- hiLo char(1) NOT NULL,
- smallBlind int,
- bigBlind int,
- smallBet int NOT NULL,
- bigBet int NOT NULL)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
- id SERIAL, PRIMARY KEY (id),
- siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
- type char(4),
- base char(4),
- category varchar(9),
- limitType char(2),
- hiLo char(1),
- smallBlind int,
- bigBlind int,
- smallBet int,
- bigBet int)"""
- elif db_server == 'sqlite':
- self.query['createGametypesTable'] = """CREATE TABLE GameTypes (
- id INTEGER PRIMARY KEY,
- siteId INTEGER,
- type TEXT,
- base TEXT,
- category TEXT,
- limitType TEXT,
- hiLo TEXT,
- smallBlind INTEGER,
- bigBlind INTEGER,
- smallBet INTEGER,
- bigBet INTEGER,
- FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
-
-
- ################################
- # Create Players
- ################################
-
- if db_server == 'mysql':
- self.query['createPlayersTable'] = """CREATE TABLE Players (
- id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- name VARCHAR(32) CHARACTER SET utf8 NOT NULL,
- siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
- comment text,
- commentTs DATETIME)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createPlayersTable'] = """CREATE TABLE Players (
- id SERIAL, PRIMARY KEY (id),
- name VARCHAR(32),
- siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
- comment text,
- commentTs timestamp without time zone)"""
- elif db_server == 'sqlite':
- self.query['createPlayersTable'] = """CREATE TABLE Players (
- id INTEGER PRIMARY KEY,
- name TEXT,
- siteId INTEGER,
- comment TEXT,
- commentTs REAL,
- FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
-
-
- ################################
- # Create Autorates
- ################################
-
- if db_server == 'mysql':
- self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
- gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- description varchar(50) NOT NULL,
- shortDesc char(8) NOT NULL,
- ratingTime DATETIME NOT NULL,
- handCount int NOT NULL)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
- id BIGSERIAL, PRIMARY KEY (id),
- playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
- gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- description varchar(50),
- shortDesc char(8),
- ratingTime timestamp without time zone,
- handCount int)"""
- elif db_server == 'sqlite':
- self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
- id INTEGER PRIMARY KEY,
- playerId INT,
- gametypeId INT,
- description TEXT,
- shortDesc TEXT,
- ratingTime REAL,
- handCount int)"""
-
-
- ################################
- # Create Hands
- ################################
-
- if db_server == 'mysql':
- self.query['createHandsTable'] = """CREATE TABLE Hands (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- tableName VARCHAR(20) NOT NULL,
- siteHandNo BIGINT NOT NULL,
- gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- handStart DATETIME NOT NULL,
- importTime DATETIME NOT NULL,
- seats TINYINT NOT NULL,
- maxSeats TINYINT NOT NULL,
- boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- boardcard2 smallint,
- boardcard3 smallint,
- boardcard4 smallint,
- boardcard5 smallint,
- texture smallint,
- playersVpi SMALLINT NOT NULL, /* num of players vpi */
- playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
- playersAtStreet2 SMALLINT NOT NULL,
- playersAtStreet3 SMALLINT NOT NULL,
- playersAtStreet4 SMALLINT NOT NULL,
- playersAtShowdown SMALLINT NOT NULL,
- street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
- street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */
- street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */
- street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */
- street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
- street1Pot INT, /* pot size at flop/street4 */
- street2Pot INT, /* pot size at turn/street5 */
- street3Pot INT, /* pot size at river/street6 */
- street4Pot INT, /* pot size at sd/street7 */
- showdownPot INT, /* pot size at sd/street7 */
- comment TEXT,
- commentTs DATETIME)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createHandsTable'] = """CREATE TABLE Hands (
- id BIGSERIAL, PRIMARY KEY (id),
- tableName VARCHAR(20) NOT NULL,
- siteHandNo BIGINT NOT NULL,
- gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- handStart timestamp without time zone NOT NULL,
- importTime timestamp without time zone NOT NULL,
- seats SMALLINT NOT NULL,
- maxSeats SMALLINT NOT NULL,
- boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- boardcard2 smallint,
- boardcard3 smallint,
- boardcard4 smallint,
- boardcard5 smallint,
- texture smallint,
- playersVpi SMALLINT NOT NULL, /* num of players vpi */
- playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
- playersAtStreet2 SMALLINT NOT NULL,
- playersAtStreet3 SMALLINT NOT NULL,
- playersAtStreet4 SMALLINT NOT NULL,
- playersAtShowdown SMALLINT NOT NULL,
- street0Raises SMALLINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
- street1Raises SMALLINT NOT NULL, /* num small bets paid to see turn/street5 */
- street2Raises SMALLINT NOT NULL, /* num big bets paid to see river/street6 */
- street3Raises SMALLINT NOT NULL, /* num big bets paid to see sd/street7 */
- street4Raises SMALLINT NOT NULL, /* num big bets paid to see showdown */
- street1Pot INT, /* pot size at flop/street4 */
- street2Pot INT, /* pot size at turn/street5 */
- street3Pot INT, /* pot size at river/street6 */
- street4Pot INT, /* pot size at sd/street7 */
- showdownPot INT, /* pot size at sd/street7 */
- comment TEXT,
- commentTs timestamp without time zone)"""
- elif db_server == 'sqlite':
- self.query['createHandsTable'] = """CREATE TABLE Hands (
- id INTEGER PRIMARY KEY,
- tableName TEXT(20) NOT NULL,
- siteHandNo INT NOT NULL,
- gametypeId INT NOT NULL,
- handStart REAL NOT NULL,
- importTime REAL NOT NULL,
- seats INT NOT NULL,
- maxSeats INT NOT NULL,
- boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- boardcard2 INT,
- boardcard3 INT,
- boardcard4 INT,
- boardcard5 INT,
- texture INT,
- playersVpi INT NOT NULL, /* num of players vpi */
- playersAtStreet1 INT NOT NULL, /* num of players seeing flop/street4 */
- playersAtStreet2 INT NOT NULL,
- playersAtStreet3 INT NOT NULL,
- playersAtStreet4 INT NOT NULL,
- playersAtShowdown INT NOT NULL,
- street0Raises INT NOT NULL, /* num small bets paid to see flop/street4, including blind */
- street1Raises INT NOT NULL, /* num small bets paid to see turn/street5 */
- street2Raises INT NOT NULL, /* num big bets paid to see river/street6 */
- street3Raises INT NOT NULL, /* num big bets paid to see sd/street7 */
- street4Raises INT NOT NULL, /* num big bets paid to see showdown */
- street1Pot INT, /* pot size at flop/street4 */
- street2Pot INT, /* pot size at turn/street5 */
- street3Pot INT, /* pot size at river/street6 */
- street4Pot INT, /* pot size at sd/street7 */
- showdownPot INT, /* pot size at sd/street7 */
- comment TEXT,
- commentTs REAL)"""
-
-
- ################################
- # Create TourneyTypes
- ################################
-
- if db_server == 'mysql':
- self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
- id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
- buyin INT NOT NULL,
- fee INT NOT NULL,
- maxSeats INT NOT NULL DEFAULT -1,
- knockout BOOLEAN NOT NULL DEFAULT False,
- rebuyOrAddon BOOLEAN NOT NULL DEFAULT False,
- speed varchar(10),
- headsUp BOOLEAN NOT NULL DEFAULT False,
- shootout BOOLEAN NOT NULL DEFAULT False,
- matrix BOOLEAN NOT NULL DEFAULT False,
- sng BOOLEAN NOT NULL DEFAULT False
- )
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
- id SERIAL, PRIMARY KEY (id),
- siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
buyin INT NOT NULL,
fee INT NOT NULL,
maxSeats INT NOT NULL DEFAULT -1,
@@ -349,2852 +332,2868 @@ class Sql:
shootout BOOLEAN NOT NULL DEFAULT False,
matrix BOOLEAN NOT NULL DEFAULT False,
sng BOOLEAN NOT NULL DEFAULT False
- )"""
- elif db_server == 'sqlite':
- self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
- id INTEGER PRIMARY KEY,
- siteId INT NOT NULL,
- buyin INT NOT NULL,
- fee INT NOT NULL,
- maxSeats INT NOT NULL DEFAULT -1,
- knockout BOOLEAN NOT NULL DEFAULT 0,
- rebuyOrAddon BOOLEAN NOT NULL DEFAULT 0,
- speed TEXT,
- headsUp BOOLEAN NOT NULL DEFAULT 0,
- shootout BOOLEAN NOT NULL DEFAULT 0,
- matrix BOOLEAN NOT NULL DEFAULT 0,
- sng BOOLEAN NOT NULL DEFAULT 0
- )"""
+ )
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
+ id SERIAL, PRIMARY KEY (id),
+ siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
+ buyin INT NOT NULL,
+ fee INT NOT NULL,
+ maxSeats INT NOT NULL DEFAULT -1,
+ knockout BOOLEAN NOT NULL DEFAULT False,
+ rebuyOrAddon BOOLEAN NOT NULL DEFAULT False,
+ speed varchar(10),
+ headsUp BOOLEAN NOT NULL DEFAULT False,
+ shootout BOOLEAN NOT NULL DEFAULT False,
+ matrix BOOLEAN NOT NULL DEFAULT False,
+ sng BOOLEAN NOT NULL DEFAULT False
+ )"""
+ elif db_server == 'sqlite':
+ self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
+ id INTEGER PRIMARY KEY,
+ siteId INT NOT NULL,
+ buyin INT NOT NULL,
+ fee INT NOT NULL,
+ maxSeats INT NOT NULL DEFAULT -1,
+ knockout BOOLEAN NOT NULL DEFAULT 0,
+ rebuyOrAddon BOOLEAN NOT NULL DEFAULT 0,
+ speed TEXT,
+ headsUp BOOLEAN NOT NULL DEFAULT 0,
+ shootout BOOLEAN NOT NULL DEFAULT 0,
+ matrix BOOLEAN NOT NULL DEFAULT 0,
+ sng BOOLEAN NOT NULL DEFAULT 0
+ )"""
- ################################
- # Create Tourneys
- ################################
+ ################################
+ # Create Tourneys
+ ################################
- if db_server == 'mysql':
- self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
- id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
- siteTourneyNo BIGINT NOT NULL,
- entries INT NOT NULL,
- prizepool INT NOT NULL,
- startTime DATETIME NOT NULL,
- endTime DATETIME,
- buyinChips INT,
- tourneyName varchar(40),
- matrixIdProcessed TINYINT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
- rebuyChips INT DEFAULT 0,
- addonChips INT DEFAULT 0,
- rebuyAmount INT DEFAULT 0,
- addonAmount INT DEFAULT 0,
- totalRebuys INT DEFAULT 0,
- totalAddons INT DEFAULT 0,
- koBounty INT DEFAULT 0,
- comment TEXT,
- commentTs DATETIME)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
- id SERIAL, PRIMARY KEY (id),
- tourneyTypeId INT DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
- siteTourneyNo BIGINT,
- entries INT,
- prizepool INT,
- startTime timestamp without time zone,
- endTime timestamp without time zone,
- buyinChips INT,
- tourneyName varchar(40),
- matrixIdProcessed SMALLINT DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
- rebuyChips INT DEFAULT 0,
- addonChips INT DEFAULT 0,
- rebuyAmount INT DEFAULT 0,
- addonAmount INT DEFAULT 0,
- totalRebuys INT DEFAULT 0,
- totalAddons INT DEFAULT 0,
- koBounty INT DEFAULT 0,
- comment TEXT,
- commentTs timestamp without time zone)"""
- elif db_server == 'sqlite':
- self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
- id INTEGER PRIMARY KEY,
- tourneyTypeId INT DEFAULT 1,
- siteTourneyNo INT,
- entries INT,
- prizepool INT,
- startTime REAL,
- endTime REAL,
- buyinChips INT,
- tourneyName TEXT,
- matrixIdProcessed INT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
- rebuyChips INT DEFAULT 0,
- addonChips INT DEFAULT 0,
- rebuyAmount INT DEFAULT 0,
- addonAmount INT DEFAULT 0,
- totalRebuys INT DEFAULT 0,
- totalAddons INT DEFAULT 0,
- koBounty INT DEFAULT 0,
- comment TEXT,
- commentTs REAL)"""
- ################################
- # Create HandsPlayers
- ################################
+ if db_server == 'mysql':
+ self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
+ id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+ siteTourneyNo BIGINT NOT NULL,
+ entries INT NOT NULL,
+ prizepool INT NOT NULL,
+ startTime DATETIME NOT NULL,
+ endTime DATETIME,
+ buyinChips INT,
+ tourneyName varchar(40),
+ matrixIdProcessed TINYINT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
+ rebuyChips INT DEFAULT 0,
+ addonChips INT DEFAULT 0,
+ rebuyAmount INT DEFAULT 0,
+ addonAmount INT DEFAULT 0,
+ totalRebuys INT DEFAULT 0,
+ totalAddons INT DEFAULT 0,
+ koBounty INT DEFAULT 0,
+ comment TEXT,
+ commentTs DATETIME)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
+ id SERIAL, PRIMARY KEY (id),
+ tourneyTypeId INT DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+ siteTourneyNo BIGINT,
+ entries INT,
+ prizepool INT,
+ startTime timestamp without time zone,
+ endTime timestamp without time zone,
+ buyinChips INT,
+ tourneyName varchar(40),
+ matrixIdProcessed SMALLINT DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
+ rebuyChips INT DEFAULT 0,
+ addonChips INT DEFAULT 0,
+ rebuyAmount INT DEFAULT 0,
+ addonAmount INT DEFAULT 0,
+ totalRebuys INT DEFAULT 0,
+ totalAddons INT DEFAULT 0,
+ koBounty INT DEFAULT 0,
+ comment TEXT,
+ commentTs timestamp without time zone)"""
+ elif db_server == 'sqlite':
+ self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
+ id INTEGER PRIMARY KEY,
+ tourneyTypeId INT DEFAULT 1,
+ siteTourneyNo INT,
+ entries INT,
+ prizepool INT,
+ startTime REAL,
+ endTime REAL,
+ buyinChips INT,
+ tourneyName TEXT,
+ matrixIdProcessed INT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
+ rebuyChips INT DEFAULT 0,
+ addonChips INT DEFAULT 0,
+ rebuyAmount INT DEFAULT 0,
+ addonAmount INT DEFAULT 0,
+ totalRebuys INT DEFAULT 0,
+ totalAddons INT DEFAULT 0,
+ koBounty INT DEFAULT 0,
+ comment TEXT,
+ commentTs REAL)"""
+ ################################
+ # Create HandsPlayers
+ ################################
- if db_server == 'mysql':
- self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
- playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
- startCash INT NOT NULL,
- position CHAR(1),
- seatNo SMALLINT NOT NULL,
+ if db_server == 'mysql':
+ self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
+ playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
+ startCash INT NOT NULL,
+ position CHAR(1),
+ seatNo SMALLINT NOT NULL,
+
+ card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ card2 smallint NOT NULL,
+ card3 smallint,
+ card4 smallint,
+ card5 smallint,
+ card6 smallint,
+ card7 smallint,
+ startCards smallint,
+
+ ante INT,
+ winnings int NOT NULL,
+ rake int NOT NULL,
+ totalProfit INT,
+ comment text,
+ commentTs DATETIME,
+ tourneysPlayersId BIGINT UNSIGNED,
+ tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+
+ wonWhenSeenStreet1 FLOAT,
+ wonWhenSeenStreet2 FLOAT,
+ wonWhenSeenStreet3 FLOAT,
+ wonWhenSeenStreet4 FLOAT,
+ wonAtSD FLOAT,
+
+ street0VPI BOOLEAN,
+ street0Aggr BOOLEAN,
+ street0_3BChance BOOLEAN,
+ street0_3BDone BOOLEAN,
+ street0_4BChance BOOLEAN,
+ street0_4BDone BOOLEAN,
+ other3BStreet0 BOOLEAN,
+ other4BStreet0 BOOLEAN,
+
+ street1Seen BOOLEAN,
+ street2Seen BOOLEAN,
+ street3Seen BOOLEAN,
+ street4Seen BOOLEAN,
+ sawShowdown BOOLEAN,
+
+ street1Aggr BOOLEAN,
+ street2Aggr BOOLEAN,
+ street3Aggr BOOLEAN,
+ street4Aggr BOOLEAN,
+
+ otherRaisedStreet0 BOOLEAN,
+ otherRaisedStreet1 BOOLEAN,
+ otherRaisedStreet2 BOOLEAN,
+ otherRaisedStreet3 BOOLEAN,
+ otherRaisedStreet4 BOOLEAN,
+ foldToOtherRaisedStreet0 BOOLEAN,
+ foldToOtherRaisedStreet1 BOOLEAN,
+ foldToOtherRaisedStreet2 BOOLEAN,
+ foldToOtherRaisedStreet3 BOOLEAN,
+ foldToOtherRaisedStreet4 BOOLEAN,
+
+ stealAttemptChance BOOLEAN,
+ stealAttempted BOOLEAN,
+ foldBbToStealChance BOOLEAN,
+ foldedBbToSteal BOOLEAN,
+ foldSbToStealChance BOOLEAN,
+ foldedSbToSteal BOOLEAN,
+
+ street1CBChance BOOLEAN,
+ street1CBDone BOOLEAN,
+ street2CBChance BOOLEAN,
+ street2CBDone BOOLEAN,
+ street3CBChance BOOLEAN,
+ street3CBDone BOOLEAN,
+ street4CBChance BOOLEAN,
+ street4CBDone BOOLEAN,
+
+ foldToStreet1CBChance BOOLEAN,
+ foldToStreet1CBDone BOOLEAN,
+ foldToStreet2CBChance BOOLEAN,
+ foldToStreet2CBDone BOOLEAN,
+ foldToStreet3CBChance BOOLEAN,
+ foldToStreet3CBDone BOOLEAN,
+ foldToStreet4CBChance BOOLEAN,
+ foldToStreet4CBDone BOOLEAN,
+
+ street1CheckCallRaiseChance BOOLEAN,
+ street1CheckCallRaiseDone BOOLEAN,
+ street2CheckCallRaiseChance BOOLEAN,
+ street2CheckCallRaiseDone BOOLEAN,
+ street3CheckCallRaiseChance BOOLEAN,
+ street3CheckCallRaiseDone BOOLEAN,
+ street4CheckCallRaiseChance BOOLEAN,
+ street4CheckCallRaiseDone BOOLEAN,
+
+ street0Calls TINYINT,
+ street1Calls TINYINT,
+ street2Calls TINYINT,
+ street3Calls TINYINT,
+ street4Calls TINYINT,
+ street0Bets TINYINT,
+ street1Bets TINYINT,
+ street2Bets TINYINT,
+ street3Bets TINYINT,
+ street4Bets TINYINT,
+ street0Raises TINYINT,
+ street1Raises TINYINT,
+ street2Raises TINYINT,
+ street3Raises TINYINT,
+ street4Raises TINYINT,
+
+ actionString VARCHAR(15),
+
+ FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
+ id BIGSERIAL, PRIMARY KEY (id),
+ handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
+ playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
+ startCash INT NOT NULL,
+ position CHAR(1),
+ seatNo SMALLINT NOT NULL,
+
+ card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ card2 smallint NOT NULL,
+ card3 smallint,
+ card4 smallint,
+ card5 smallint,
+ card6 smallint,
+ card7 smallint,
+ startCards smallint,
+
+ ante INT,
+ winnings int NOT NULL,
+ rake int NOT NULL,
+ totalProfit INT,
+ comment text,
+ commentTs timestamp without time zone,
+ tourneysPlayersId BIGINT,
+ tourneyTypeId INT NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+
+ wonWhenSeenStreet1 FLOAT,
+ wonWhenSeenStreet2 FLOAT,
+ wonWhenSeenStreet3 FLOAT,
+ wonWhenSeenStreet4 FLOAT,
+ wonAtSD FLOAT,
+
+ street0VPI BOOLEAN,
+ street0Aggr BOOLEAN,
+ street0_3BChance BOOLEAN,
+ street0_3BDone BOOLEAN,
+ street0_4BChance BOOLEAN,
+ street0_4BDone BOOLEAN,
+ other3BStreet0 BOOLEAN,
+ other4BStreet0 BOOLEAN,
+
+ street1Seen BOOLEAN,
+ street2Seen BOOLEAN,
+ street3Seen BOOLEAN,
+ street4Seen BOOLEAN,
+ sawShowdown BOOLEAN,
+
+ street1Aggr BOOLEAN,
+ street2Aggr BOOLEAN,
+ street3Aggr BOOLEAN,
+ street4Aggr BOOLEAN,
+
+ otherRaisedStreet0 BOOLEAN,
+ otherRaisedStreet1 BOOLEAN,
+ otherRaisedStreet2 BOOLEAN,
+ otherRaisedStreet3 BOOLEAN,
+ otherRaisedStreet4 BOOLEAN,
+ foldToOtherRaisedStreet0 BOOLEAN,
+ foldToOtherRaisedStreet1 BOOLEAN,
+ foldToOtherRaisedStreet2 BOOLEAN,
+ foldToOtherRaisedStreet3 BOOLEAN,
+ foldToOtherRaisedStreet4 BOOLEAN,
+
+ stealAttemptChance BOOLEAN,
+ stealAttempted BOOLEAN,
+ foldBbToStealChance BOOLEAN,
+ foldedBbToSteal BOOLEAN,
+ foldSbToStealChance BOOLEAN,
+ foldedSbToSteal BOOLEAN,
+
+ street1CBChance BOOLEAN,
+ street1CBDone BOOLEAN,
+ street2CBChance BOOLEAN,
+ street2CBDone BOOLEAN,
+ street3CBChance BOOLEAN,
+ street3CBDone BOOLEAN,
+ street4CBChance BOOLEAN,
+ street4CBDone BOOLEAN,
+
+ foldToStreet1CBChance BOOLEAN,
+ foldToStreet1CBDone BOOLEAN,
+ foldToStreet2CBChance BOOLEAN,
+ foldToStreet2CBDone BOOLEAN,
+ foldToStreet3CBChance BOOLEAN,
+ foldToStreet3CBDone BOOLEAN,
+ foldToStreet4CBChance BOOLEAN,
+ foldToStreet4CBDone BOOLEAN,
+
+ street1CheckCallRaiseChance BOOLEAN,
+ street1CheckCallRaiseDone BOOLEAN,
+ street2CheckCallRaiseChance BOOLEAN,
+ street2CheckCallRaiseDone BOOLEAN,
+ street3CheckCallRaiseChance BOOLEAN,
+ street3CheckCallRaiseDone BOOLEAN,
+ street4CheckCallRaiseChance BOOLEAN,
+ street4CheckCallRaiseDone BOOLEAN,
+
+ street0Calls SMALLINT,
+ street1Calls SMALLINT,
+ street2Calls SMALLINT,
+ street3Calls SMALLINT,
+ street4Calls SMALLINT,
+ street0Bets SMALLINT,
+ street1Bets SMALLINT,
+ street2Bets SMALLINT,
+ street3Bets SMALLINT,
+ street4Bets SMALLINT,
+ street0Raises SMALLINT,
+ street1Raises SMALLINT,
+ street2Raises SMALLINT,
+ street3Raises SMALLINT,
+ street4Raises SMALLINT,
+
+ actionString VARCHAR(15),
+
+ FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))"""
+ elif db_server == 'sqlite':
+ self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
+ id INTEGER PRIMARY KEY,
+ handId INT NOT NULL,
+ playerId INT NOT NULL,
+ startCash INT NOT NULL,
+ position TEXT,
+ seatNo INT NOT NULL,
+
+ card1 INT NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
+ card2 INT NOT NULL,
+ card3 INT,
+ card4 INT,
+ card5 INT,
+ card6 INT,
+ card7 INT,
+ startCards INT,
+
+ ante INT,
+ winnings INT NOT NULL,
+ rake INT NOT NULL,
+ totalProfit INT,
+ comment TEXT,
+ commentTs REAL,
+ tourneysPlayersId INT,
+ tourneyTypeId INT NOT NULL DEFAULT 1,
+
+ wonWhenSeenStreet1 REAL,
+ wonWhenSeenStreet2 REAL,
+ wonWhenSeenStreet3 REAL,
+ wonWhenSeenStreet4 REAL,
+ wonAtSD REAL,
+
+ street0VPI INT,
+ street0Aggr INT,
+ street0_3BChance INT,
+ street0_3BDone INT,
+ street0_4BChance INT,
+ street0_4BDone INT,
+ other3BStreet0 INT,
+ other4BStreet0 INT,
+
+ street1Seen INT,
+ street2Seen INT,
+ street3Seen INT,
+ street4Seen INT,
+ sawShowdown INT,
+
+ street1Aggr INT,
+ street2Aggr INT,
+ street3Aggr INT,
+ street4Aggr INT,
+
+ otherRaisedStreet0 INT,
+ otherRaisedStreet1 INT,
+ otherRaisedStreet2 INT,
+ otherRaisedStreet3 INT,
+ otherRaisedStreet4 INT,
+ foldToOtherRaisedStreet0 INT,
+ foldToOtherRaisedStreet1 INT,
+ foldToOtherRaisedStreet2 INT,
+ foldToOtherRaisedStreet3 INT,
+ foldToOtherRaisedStreet4 INT,
+
+ stealAttemptChance INT,
+ stealAttempted INT,
+ foldBbToStealChance INT,
+ foldedBbToSteal INT,
+ foldSbToStealChance INT,
+ foldedSbToSteal INT,
+
+ street1CBChance INT,
+ street1CBDone INT,
+ street2CBChance INT,
+ street2CBDone INT,
+ street3CBChance INT,
+ street3CBDone INT,
+ street4CBChance INT,
+ street4CBDone INT,
+
+ foldToStreet1CBChance INT,
+ foldToStreet1CBDone INT,
+ foldToStreet2CBChance INT,
+ foldToStreet2CBDone INT,
+ foldToStreet3CBChance INT,
+ foldToStreet3CBDone INT,
+ foldToStreet4CBChance INT,
+ foldToStreet4CBDone INT,
+
+ street1CheckCallRaiseChance INT,
+ street1CheckCallRaiseDone INT,
+ street2CheckCallRaiseChance INT,
+ street2CheckCallRaiseDone INT,
+ street3CheckCallRaiseChance INT,
+ street3CheckCallRaiseDone INT,
+ street4CheckCallRaiseChance INT,
+ street4CheckCallRaiseDone INT,
+
+ street0Calls INT,
+ street1Calls INT,
+ street2Calls INT,
+ street3Calls INT,
+ street4Calls INT,
+ street0Bets INT,
+ street1Bets INT,
+ street2Bets INT,
+ street3Bets INT,
+ street4Bets INT,
+ street0Raises INT,
+ street1Raises INT,
+ street2Raises INT,
+ street3Raises INT,
+ street4Raises INT,
+
+ actionString REAL)
+ """
+
+
+ ################################
+ # Create TourneysPlayers
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
+ playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
+ payinAmount INT NOT NULL,
+ rank INT NOT NULL,
+ winnings INT NOT NULL,
+ nbRebuys INT DEFAULT 0,
+ nbAddons INT DEFAULT 0,
+ nbKO INT DEFAULT 0,
+ comment TEXT,
+ commentTs DATETIME)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
+ id BIGSERIAL, PRIMARY KEY (id),
+ tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
+ playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
+ payinAmount INT,
+ rank INT,
+ winnings INT,
+ nbRebuys INT DEFAULT 0,
+ nbAddons INT DEFAULT 0,
+ nbKO INT DEFAULT 0,
+ comment TEXT,
+ commentTs timestamp without time zone)"""
+ elif db_server == 'sqlite':
+ self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
+ id INT PRIMARY KEY,
+ tourneyId INT,
+ playerId INT,
+ payinAmount INT,
+ rank INT,
+ winnings INT,
+ nbRebuys INT DEFAULT 0,
+ nbAddons INT DEFAULT 0,
+ nbKO INT DEFAULT 0,
+ comment TEXT,
+ commentTs timestamp without time zone,
+ FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
+ FOREIGN KEY (playerId) REFERENCES Players(id)
+ )"""
+
+
+ ################################
+ # Create HandsActions
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
+ street SMALLINT NOT NULL,
+ actionNo SMALLINT NOT NULL,
+ action CHAR(5) NOT NULL,
+ allIn BOOLEAN NOT NULL,
+ amount INT NOT NULL,
+ comment TEXT,
+ commentTs DATETIME)
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
+ id BIGSERIAL, PRIMARY KEY (id),
+ handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
+ street SMALLINT,
+ actionNo SMALLINT,
+ action CHAR(5),
+ allIn BOOLEAN,
+ amount INT,
+ comment TEXT,
+ commentTs timestamp without time zone)"""
+ elif db_server == 'sqlite':
+ self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
+ id INT PRIMARY KEY,
+ handsPlayerId BIGINT,
+ street SMALLINT,
+ actionNo SMALLINT,
+ action CHAR(5),
+ allIn INT,
+ amount INT,
+ comment TEXT,
+ commentTs timestamp without time zone,
+ FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id)
+ )"""
+
+
+ ################################
+ # Create HudCache
+ ################################
+
+ if db_server == 'mysql':
+ self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
+ id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
+ gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
+ activeSeats SMALLINT NOT NULL,
+ position CHAR(1),
+ tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+ styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
+ HDs INT NOT NULL,
+
+ wonWhenSeenStreet1 FLOAT,
+ wonWhenSeenStreet2 FLOAT,
+ wonWhenSeenStreet3 FLOAT,
+ wonWhenSeenStreet4 FLOAT,
+ wonAtSD FLOAT,
+
+ street0VPI INT,
+ street0Aggr INT,
+ street0_3BChance INT,
+ street0_3BDone INT,
+ street0_4BChance INT,
+ street0_4BDone INT,
+ other3BStreet0 INT,
+ other4BStreet0 INT,
+
+ street1Seen INT,
+ street2Seen INT,
+ street3Seen INT,
+ street4Seen INT,
+ sawShowdown INT,
- card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- card2 smallint NOT NULL,
- card3 smallint,
- card4 smallint,
- card5 smallint,
- card6 smallint,
- card7 smallint,
- startCards smallint,
+ street1Aggr INT,
+ street2Aggr INT,
+ street3Aggr INT,
+ street4Aggr INT,
+
+ otherRaisedStreet0 INT,
+ otherRaisedStreet1 INT,
+ otherRaisedStreet2 INT,
+ otherRaisedStreet3 INT,
+ otherRaisedStreet4 INT,
+ foldToOtherRaisedStreet0 INT,
+ foldToOtherRaisedStreet1 INT,
+ foldToOtherRaisedStreet2 INT,
+ foldToOtherRaisedStreet3 INT,
+ foldToOtherRaisedStreet4 INT,
- ante INT,
- winnings int NOT NULL,
- rake int NOT NULL,
- totalProfit INT,
- comment text,
- commentTs DATETIME,
- tourneysPlayersId BIGINT UNSIGNED,
- tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+ stealAttemptChance INT,
+ stealAttempted INT,
+ foldBbToStealChance INT,
+ foldedBbToSteal INT,
+ foldSbToStealChance INT,
+ foldedSbToSteal INT,
- wonWhenSeenStreet1 FLOAT,
- wonWhenSeenStreet2 FLOAT,
- wonWhenSeenStreet3 FLOAT,
- wonWhenSeenStreet4 FLOAT,
- wonAtSD FLOAT,
-
- street0VPI BOOLEAN,
- street0Aggr BOOLEAN,
- street0_3BChance BOOLEAN,
- street0_3BDone BOOLEAN,
- street0_4BChance BOOLEAN,
- street0_4BDone BOOLEAN,
- other3BStreet0 BOOLEAN,
- other4BStreet0 BOOLEAN,
-
- street1Seen BOOLEAN,
- street2Seen BOOLEAN,
- street3Seen BOOLEAN,
- street4Seen BOOLEAN,
- sawShowdown BOOLEAN,
-
- street1Aggr BOOLEAN,
- street2Aggr BOOLEAN,
- street3Aggr BOOLEAN,
- street4Aggr BOOLEAN,
-
- otherRaisedStreet0 BOOLEAN,
- otherRaisedStreet1 BOOLEAN,
- otherRaisedStreet2 BOOLEAN,
- otherRaisedStreet3 BOOLEAN,
- otherRaisedStreet4 BOOLEAN,
- foldToOtherRaisedStreet0 BOOLEAN,
- foldToOtherRaisedStreet1 BOOLEAN,
- foldToOtherRaisedStreet2 BOOLEAN,
- foldToOtherRaisedStreet3 BOOLEAN,
- foldToOtherRaisedStreet4 BOOLEAN,
-
- stealAttemptChance BOOLEAN,
- stealAttempted BOOLEAN,
- foldBbToStealChance BOOLEAN,
- foldedBbToSteal BOOLEAN,
- foldSbToStealChance BOOLEAN,
- foldedSbToSteal BOOLEAN,
-
- street1CBChance BOOLEAN,
- street1CBDone BOOLEAN,
- street2CBChance BOOLEAN,
- street2CBDone BOOLEAN,
- street3CBChance BOOLEAN,
- street3CBDone BOOLEAN,
- street4CBChance BOOLEAN,
- street4CBDone BOOLEAN,
-
- foldToStreet1CBChance BOOLEAN,
- foldToStreet1CBDone BOOLEAN,
- foldToStreet2CBChance BOOLEAN,
- foldToStreet2CBDone BOOLEAN,
- foldToStreet3CBChance BOOLEAN,
- foldToStreet3CBDone BOOLEAN,
- foldToStreet4CBChance BOOLEAN,
- foldToStreet4CBDone BOOLEAN,
-
- street1CheckCallRaiseChance BOOLEAN,
- street1CheckCallRaiseDone BOOLEAN,
- street2CheckCallRaiseChance BOOLEAN,
- street2CheckCallRaiseDone BOOLEAN,
- street3CheckCallRaiseChance BOOLEAN,
- street3CheckCallRaiseDone BOOLEAN,
- street4CheckCallRaiseChance BOOLEAN,
- street4CheckCallRaiseDone BOOLEAN,
-
- street0Calls TINYINT,
- street1Calls TINYINT,
- street2Calls TINYINT,
- street3Calls TINYINT,
- street4Calls TINYINT,
- street0Bets TINYINT,
- street1Bets TINYINT,
- street2Bets TINYINT,
- street3Bets TINYINT,
- street4Bets TINYINT,
- street0Raises TINYINT,
- street1Raises TINYINT,
- street2Raises TINYINT,
- street3Raises TINYINT,
- street4Raises TINYINT,
-
- actionString VARCHAR(15),
-
- FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
- id BIGSERIAL, PRIMARY KEY (id),
- handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
- playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
- startCash INT NOT NULL,
- position CHAR(1),
- seatNo SMALLINT NOT NULL,
-
- card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- card2 smallint NOT NULL,
- card3 smallint,
- card4 smallint,
- card5 smallint,
- card6 smallint,
- card7 smallint,
- startCards smallint,
-
- ante INT,
- winnings int NOT NULL,
- rake int NOT NULL,
- totalProfit INT,
- comment text,
- commentTs timestamp without time zone,
- tourneysPlayersId BIGINT,
- tourneyTypeId INT NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
-
- wonWhenSeenStreet1 FLOAT,
- wonWhenSeenStreet2 FLOAT,
- wonWhenSeenStreet3 FLOAT,
- wonWhenSeenStreet4 FLOAT,
- wonAtSD FLOAT,
-
- street0VPI BOOLEAN,
- street0Aggr BOOLEAN,
- street0_3BChance BOOLEAN,
- street0_3BDone BOOLEAN,
- street0_4BChance BOOLEAN,
- street0_4BDone BOOLEAN,
- other3BStreet0 BOOLEAN,
- other4BStreet0 BOOLEAN,
-
- street1Seen BOOLEAN,
- street2Seen BOOLEAN,
- street3Seen BOOLEAN,
- street4Seen BOOLEAN,
- sawShowdown BOOLEAN,
-
- street1Aggr BOOLEAN,
- street2Aggr BOOLEAN,
- street3Aggr BOOLEAN,
- street4Aggr BOOLEAN,
-
- otherRaisedStreet0 BOOLEAN,
- otherRaisedStreet1 BOOLEAN,
- otherRaisedStreet2 BOOLEAN,
- otherRaisedStreet3 BOOLEAN,
- otherRaisedStreet4 BOOLEAN,
- foldToOtherRaisedStreet0 BOOLEAN,
- foldToOtherRaisedStreet1 BOOLEAN,
- foldToOtherRaisedStreet2 BOOLEAN,
- foldToOtherRaisedStreet3 BOOLEAN,
- foldToOtherRaisedStreet4 BOOLEAN,
-
- stealAttemptChance BOOLEAN,
- stealAttempted BOOLEAN,
- foldBbToStealChance BOOLEAN,
- foldedBbToSteal BOOLEAN,
- foldSbToStealChance BOOLEAN,
- foldedSbToSteal BOOLEAN,
-
- street1CBChance BOOLEAN,
- street1CBDone BOOLEAN,
- street2CBChance BOOLEAN,
- street2CBDone BOOLEAN,
- street3CBChance BOOLEAN,
- street3CBDone BOOLEAN,
- street4CBChance BOOLEAN,
- street4CBDone BOOLEAN,
-
- foldToStreet1CBChance BOOLEAN,
- foldToStreet1CBDone BOOLEAN,
- foldToStreet2CBChance BOOLEAN,
- foldToStreet2CBDone BOOLEAN,
- foldToStreet3CBChance BOOLEAN,
- foldToStreet3CBDone BOOLEAN,
- foldToStreet4CBChance BOOLEAN,
- foldToStreet4CBDone BOOLEAN,
-
- street1CheckCallRaiseChance BOOLEAN,
- street1CheckCallRaiseDone BOOLEAN,
- street2CheckCallRaiseChance BOOLEAN,
- street2CheckCallRaiseDone BOOLEAN,
- street3CheckCallRaiseChance BOOLEAN,
- street3CheckCallRaiseDone BOOLEAN,
- street4CheckCallRaiseChance BOOLEAN,
- street4CheckCallRaiseDone BOOLEAN,
-
- street0Calls SMALLINT,
- street1Calls SMALLINT,
- street2Calls SMALLINT,
- street3Calls SMALLINT,
- street4Calls SMALLINT,
- street0Bets SMALLINT,
- street1Bets SMALLINT,
- street2Bets SMALLINT,
- street3Bets SMALLINT,
- street4Bets SMALLINT,
- street0Raises SMALLINT,
- street1Raises SMALLINT,
- street2Raises SMALLINT,
- street3Raises SMALLINT,
- street4Raises SMALLINT,
-
- actionString VARCHAR(15),
-
- FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))"""
- elif db_server == 'sqlite':
- self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
- id INTEGER PRIMARY KEY,
- handId INT NOT NULL,
- playerId INT NOT NULL,
- startCash INT NOT NULL,
- position TEXT,
- seatNo INT NOT NULL,
+ street1CBChance INT,
+ street1CBDone INT,
+ street2CBChance INT,
+ street2CBDone INT,
+ street3CBChance INT,
+ street3CBDone INT,
+ street4CBChance INT,
+ street4CBDone INT,
- card1 INT NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
- card2 INT NOT NULL,
- card3 INT,
- card4 INT,
- card5 INT,
- card6 INT,
- card7 INT,
- startCards INT,
+ foldToStreet1CBChance INT,
+ foldToStreet1CBDone INT,
+ foldToStreet2CBChance INT,
+ foldToStreet2CBDone INT,
+ foldToStreet3CBChance INT,
+ foldToStreet3CBDone INT,
+ foldToStreet4CBChance INT,
+ foldToStreet4CBDone INT,
- ante INT,
- winnings INT NOT NULL,
- rake INT NOT NULL,
- totalProfit INT,
- comment TEXT,
- commentTs REAL,
- tourneysPlayersId INT,
- tourneyTypeId INT NOT NULL DEFAULT 1,
+ totalProfit INT,
+
+ street1CheckCallRaiseChance INT,
+ street1CheckCallRaiseDone INT,
+ street2CheckCallRaiseChance INT,
+ street2CheckCallRaiseDone INT,
+ street3CheckCallRaiseChance INT,
+ street3CheckCallRaiseDone INT,
+ street4CheckCallRaiseChance INT,
+ street4CheckCallRaiseDone INT,
- wonWhenSeenStreet1 REAL,
- wonWhenSeenStreet2 REAL,
- wonWhenSeenStreet3 REAL,
- wonWhenSeenStreet4 REAL,
- wonAtSD REAL,
+ street0Calls INT,
+ street1Calls INT,
+ street2Calls INT,
+ street3Calls INT,
+ street4Calls INT,
+ street0Bets INT,
+ street1Bets INT,
+ street2Bets INT,
+ street3Bets INT,
+ street4Bets INT,
+ street0Raises INT,
+ street1Raises INT,
+ street2Raises INT,
+ street3Raises INT,
+ street4Raises INT)
- street0VPI INT,
- street0Aggr INT,
- street0_3BChance INT,
- street0_3BDone INT,
- street0_4BChance INT,
- street0_4BDone INT,
- other3BStreet0 INT,
- other4BStreet0 INT,
+ ENGINE=INNODB"""
+ elif db_server == 'postgresql':
+ self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
+ id BIGSERIAL, PRIMARY KEY (id),
+ gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
+ playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
+ activeSeats SMALLINT,
+ position CHAR(1),
+ tourneyTypeId INT DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
+ styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
+ HDs INT,
- street1Seen INT,
- street2Seen INT,
- street3Seen INT,
- street4Seen INT,
- sawShowdown INT,
+ wonWhenSeenStreet1 FLOAT,
+ wonWhenSeenStreet2 FLOAT,
+ wonWhenSeenStreet3 FLOAT,
+ wonWhenSeenStreet4 FLOAT,
+ wonAtSD FLOAT,
- street1Aggr INT,
- street2Aggr INT,
- street3Aggr INT,
- street4Aggr INT,
+ street0VPI INT,
+ street0Aggr INT,
+ street0_3BChance INT,
+ street0_3BDone INT,
+ street0_4BChance INT,
+ street0_4BDone INT,
+ other3BStreet0 INT,
+ other4BStreet0 INT,
- otherRaisedStreet0 INT,
- otherRaisedStreet1 INT,
- otherRaisedStreet2 INT,
- otherRaisedStreet3 INT,
- otherRaisedStreet4 INT,
- foldToOtherRaisedStreet0 INT,
- foldToOtherRaisedStreet1 INT,
- foldToOtherRaisedStreet2 INT,
- foldToOtherRaisedStreet3 INT,
- foldToOtherRaisedStreet4 INT,
+ street1Seen INT,
+ street2Seen INT,
+ street3Seen INT,
+ street4Seen INT,
+ sawShowdown INT,
+ street1Aggr INT,
+ street2Aggr INT,
+ street3Aggr INT,
+ street4Aggr INT,
- stealAttemptChance INT,
- stealAttempted INT,
- foldBbToStealChance INT,
- foldedBbToSteal INT,
- foldSbToStealChance INT,
- foldedSbToSteal INT,
+ otherRaisedStreet0 INT,
+ otherRaisedStreet1 INT,
+ otherRaisedStreet2 INT,
+ otherRaisedStreet3 INT,
+ otherRaisedStreet4 INT,
+ foldToOtherRaisedStreet0 INT,
+ foldToOtherRaisedStreet1 INT,
+ foldToOtherRaisedStreet2 INT,
+ foldToOtherRaisedStreet3 INT,
+ foldToOtherRaisedStreet4 INT,
- street1CBChance INT,
- street1CBDone INT,
- street2CBChance INT,
- street2CBDone INT,
- street3CBChance INT,
- street3CBDone INT,
- street4CBChance INT,
- street4CBDone INT,
+ stealAttemptChance INT,
+ stealAttempted INT,
+ foldBbToStealChance INT,
+ foldedBbToSteal INT,
+ foldSbToStealChance INT,
+ foldedSbToSteal INT,
- foldToStreet1CBChance INT,
- foldToStreet1CBDone INT,
- foldToStreet2CBChance INT,
- foldToStreet2CBDone INT,
- foldToStreet3CBChance INT,
- foldToStreet3CBDone INT,
- foldToStreet4CBChance INT,
- foldToStreet4CBDone INT,
+ street1CBChance INT,
+ street1CBDone INT,
+ street2CBChance INT,
+ street2CBDone INT,
+ street3CBChance INT,
+ street3CBDone INT,
+ street4CBChance INT,
+ street4CBDone INT,
- street1CheckCallRaiseChance INT,
- street1CheckCallRaiseDone INT,
- street2CheckCallRaiseChance INT,
- street2CheckCallRaiseDone INT,
- street3CheckCallRaiseChance INT,
- street3CheckCallRaiseDone INT,
- street4CheckCallRaiseChance INT,
- street4CheckCallRaiseDone INT,
+ foldToStreet1CBChance INT,
+ foldToStreet1CBDone INT,
+ foldToStreet2CBChance INT,
+ foldToStreet2CBDone INT,
+ foldToStreet3CBChance INT,
+ foldToStreet3CBDone INT,
+ foldToStreet4CBChance INT,
+ foldToStreet4CBDone INT,
- street0Calls INT,
- street1Calls INT,
- street2Calls INT,
- street3Calls INT,
- street4Calls INT,
- street0Bets INT,
- street1Bets INT,
- street2Bets INT,
- street3Bets INT,
- street4Bets INT,
- street0Raises INT,
- street1Raises INT,
- street2Raises INT,
- street3Raises INT,
- street4Raises INT,
+ totalProfit INT,
- actionString REAL)
- """
+ street1CheckCallRaiseChance INT,
+ street1CheckCallRaiseDone INT,
+ street2CheckCallRaiseChance INT,
+ street2CheckCallRaiseDone INT,
+ street3CheckCallRaiseChance INT,
+ street3CheckCallRaiseDone INT,
+ street4CheckCallRaiseChance INT,
+ street4CheckCallRaiseDone INT,
+
+ street0Calls INT,
+ street1Calls INT,
+ street2Calls INT,
+ street3Calls INT,
+ street4Calls INT,
+ street0Bets INT,
+ street1Bets INT,
+ street2Bets INT,
+ street3Bets INT,
+ street4Bets INT,
+ street0Raises INT,
+ street1Raises INT,
+ street2Raises INT,
+ street3Raises INT,
+ street4Raises INT)
+ """
+ elif db_server == 'sqlite':
+ self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
+ id INTEGER PRIMARY KEY,
+ gametypeId INT,
+ playerId INT,
+ activeSeats INT,
+ position TEXT,
+ tourneyTypeId INT DEFAULT 1,
+ styleKey TEXT NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
+ HDs INT,
+
+ wonWhenSeenStreet1 REAL,
+ wonWhenSeenStreet2 REAL,
+ wonWhenSeenStreet3 REAL,
+ wonWhenSeenStreet4 REAL,
+ wonAtSD REAL,
+
+ street0VPI INT,
+ street0Aggr INT,
+ street0_3BChance INT,
+ street0_3BDone INT,
+ street0_4BChance INT,
+ street0_4BDone INT,
+ other3BStreet0 INT,
+ other4BStreet0 INT,
+
+ street1Seen INT,
+ street2Seen INT,
+ street3Seen INT,
+ street4Seen INT,
+ sawShowdown INT,
+ street1Aggr INT,
+ street2Aggr INT,
+ street3Aggr INT,
+ street4Aggr INT,
+
+ otherRaisedStreet0 INT,
+ otherRaisedStreet1 INT,
+ otherRaisedStreet2 INT,
+ otherRaisedStreet3 INT,
+ otherRaisedStreet4 INT,
+ foldToOtherRaisedStreet0 INT,
+ foldToOtherRaisedStreet1 INT,
+ foldToOtherRaisedStreet2 INT,
+ foldToOtherRaisedStreet3 INT,
+ foldToOtherRaisedStreet4 INT,
+
+ stealAttemptChance INT,
+ stealAttempted INT,
+ foldBbToStealChance INT,
+ foldedBbToSteal INT,
+ foldSbToStealChance INT,
+ foldedSbToSteal INT,
+
+ street1CBChance INT,
+ street1CBDone INT,
+ street2CBChance INT,
+ street2CBDone INT,
+ street3CBChance INT,
+ street3CBDone INT,
+ street4CBChance INT,
+ street4CBDone INT,
+
+ foldToStreet1CBChance INT,
+ foldToStreet1CBDone INT,
+ foldToStreet2CBChance INT,
+ foldToStreet2CBDone INT,
+ foldToStreet3CBChance INT,
+ foldToStreet3CBDone INT,
+ foldToStreet4CBChance INT,
+ foldToStreet4CBDone INT,
+
+ totalProfit INT,
+
+ street1CheckCallRaiseChance INT,
+ street1CheckCallRaiseDone INT,
+ street2CheckCallRaiseChance INT,
+ street2CheckCallRaiseDone INT,
+ street3CheckCallRaiseChance INT,
+ street3CheckCallRaiseDone INT,
+ street4CheckCallRaiseChance INT,
+ street4CheckCallRaiseDone INT,
+
+ street0Calls INT,
+ street1Calls INT,
+ street2Calls INT,
+ street3Calls INT,
+ street4Calls INT,
+ street0Bets INT,
+ street1Bets INT,
+ street2Bets INT,
+ street3Bets INT,
+ street4Bets INT,
+ street0Raises INT,
+ street1Raises INT,
+ street2Raises INT,
+ street3Raises INT,
+ street4Raises INT)
+ """
- ################################
- # Create TourneysPlayers
- ################################
+ if db_server == 'mysql':
+ self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD UNIQUE INDEX siteTourneyNo(siteTourneyNo, tourneyTypeId)"""
+ elif db_server == 'postgresql':
+ self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
+ elif db_server == 'sqlite':
+ self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
- if db_server == 'mysql':
- self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
- playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
- payinAmount INT NOT NULL,
- rank INT NOT NULL,
- winnings INT NOT NULL,
- nbRebuys INT DEFAULT 0,
- nbAddons INT DEFAULT 0,
- nbKO INT DEFAULT 0,
- comment TEXT,
- commentTs DATETIME)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
- id BIGSERIAL, PRIMARY KEY (id),
- tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
- playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
- payinAmount INT,
- rank INT,
- winnings INT,
- nbRebuys INT DEFAULT 0,
- nbAddons INT DEFAULT 0,
- nbKO INT DEFAULT 0,
- comment TEXT,
- commentTs timestamp without time zone)"""
- elif db_server == 'sqlite':
- self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
- id INT PRIMARY KEY,
- tourneyId INT,
- playerId INT,
- payinAmount INT,
- rank INT,
- winnings INT,
- nbRebuys INT DEFAULT 0,
- nbAddons INT DEFAULT 0,
- nbKO INT DEFAULT 0,
- comment TEXT,
- commentTs timestamp without time zone,
- FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
- FOREIGN KEY (playerId) REFERENCES Players(id)
- )"""
+ if db_server == 'mysql':
+ self.query['addHandsIndex'] = """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gameTypeId)"""
+ elif db_server == 'postgresql':
+ self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)"""
+ elif db_server == 'sqlite':
+ self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)"""
+ if db_server == 'mysql':
+ self.query['addPlayersIndex'] = """ALTER TABLE Players ADD UNIQUE INDEX name(name, siteId)"""
+ elif db_server == 'postgresql':
+ self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
+ elif db_server == 'sqlite':
+ self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
- ################################
- # Create HandsActions
- ################################
+ if db_server == 'mysql':
+ self.query['addTPlayersIndex'] = """ALTER TABLE TourneysPlayers ADD UNIQUE INDEX tourneyId(tourneyId, playerId)"""
+ elif db_server == 'postgresql':
+ self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId)"""
+ elif db_server == 'sqlite':
+ self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId)"""
- if db_server == 'mysql':
- self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
- street SMALLINT NOT NULL,
- actionNo SMALLINT NOT NULL,
- action CHAR(5) NOT NULL,
- allIn BOOLEAN NOT NULL,
- amount INT NOT NULL,
- comment TEXT,
- commentTs DATETIME)
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
- id BIGSERIAL, PRIMARY KEY (id),
- handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
- street SMALLINT,
- actionNo SMALLINT,
- action CHAR(5),
- allIn BOOLEAN,
- amount INT,
- comment TEXT,
- commentTs timestamp without time zone)"""
- elif db_server == 'sqlite':
- self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
- id INT PRIMARY KEY,
- handsPlayerId BIGINT,
- street SMALLINT,
- actionNo SMALLINT,
- action CHAR(5),
- allIn INT,
- amount INT,
- comment TEXT,
- commentTs timestamp without time zone,
- FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id)
- )"""
+ if db_server == 'mysql':
+ self.query['addTTypesIndex'] = """ALTER TABLE TourneyTypes ADD UNIQUE INDEX tourneytypes_all(buyin, fee
+ , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
+ elif db_server == 'postgresql':
+ self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
+ , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
+ elif db_server == 'sqlite':
+ self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
+ , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
+ self.query['get_last_hand'] = "select max(id) from Hands"
- ################################
- # Create HudCache
- ################################
+ self.query['get_player_id'] = """
+ select Players.id AS player_id
+ from Players, Sites
+ where Players.name = %s
+ and Sites.name = %s
+ and Players.siteId = Sites.id
+ """
- if db_server == 'mysql':
- self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
- id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
- gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
- activeSeats SMALLINT NOT NULL,
- position CHAR(1),
- tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
- styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
- HDs INT NOT NULL,
+ self.query['get_player_names'] = """
+ select p.name
+ from Players p
+ where lower(p.name) like lower(%s)
+ and (p.siteId = %s or %s = -1)
+ """
- wonWhenSeenStreet1 FLOAT,
- wonWhenSeenStreet2 FLOAT,
- wonWhenSeenStreet3 FLOAT,
- wonWhenSeenStreet4 FLOAT,
- wonAtSD FLOAT,
+ self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
- street0VPI INT,
- street0Aggr INT,
- street0_3BChance INT,
- street0_3BDone INT,
- street0_4BChance INT,
- street0_4BDone INT,
- other3BStreet0 INT,
- other4BStreet0 INT,
-
- street1Seen INT,
- street2Seen INT,
- street3Seen INT,
- street4Seen INT,
- sawShowdown INT,
-
- street1Aggr INT,
- street2Aggr INT,
- street3Aggr INT,
- street4Aggr INT,
-
- otherRaisedStreet0 INT,
- otherRaisedStreet1 INT,
- otherRaisedStreet2 INT,
- otherRaisedStreet3 INT,
- otherRaisedStreet4 INT,
- foldToOtherRaisedStreet0 INT,
- foldToOtherRaisedStreet1 INT,
- foldToOtherRaisedStreet2 INT,
- foldToOtherRaisedStreet3 INT,
- foldToOtherRaisedStreet4 INT,
-
- stealAttemptChance INT,
- stealAttempted INT,
- foldBbToStealChance INT,
- foldedBbToSteal INT,
- foldSbToStealChance INT,
- foldedSbToSteal INT,
-
- street1CBChance INT,
- street1CBDone INT,
- street2CBChance INT,
- street2CBDone INT,
- street3CBChance INT,
- street3CBDone INT,
- street4CBChance INT,
- street4CBDone INT,
-
- foldToStreet1CBChance INT,
- foldToStreet1CBDone INT,
- foldToStreet2CBChance INT,
- foldToStreet2CBDone INT,
- foldToStreet3CBChance INT,
- foldToStreet3CBDone INT,
- foldToStreet4CBChance INT,
- foldToStreet4CBDone INT,
-
- totalProfit INT,
-
- street1CheckCallRaiseChance INT,
- street1CheckCallRaiseDone INT,
- street2CheckCallRaiseChance INT,
- street2CheckCallRaiseDone INT,
- street3CheckCallRaiseChance INT,
- street3CheckCallRaiseDone INT,
- street4CheckCallRaiseChance INT,
- street4CheckCallRaiseDone INT,
-
- street0Calls INT,
- street1Calls INT,
- street2Calls INT,
- street3Calls INT,
- street4Calls INT,
- street0Bets INT,
- street1Bets INT,
- street2Bets INT,
- street3Bets INT,
- street4Bets INT,
- street0Raises INT,
- street1Raises INT,
- street2Raises INT,
- street3Raises INT,
- street4Raises INT)
-
- ENGINE=INNODB"""
- elif db_server == 'postgresql':
- self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
- id BIGSERIAL, PRIMARY KEY (id),
- gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
- playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
- activeSeats SMALLINT,
- position CHAR(1),
- tourneyTypeId INT DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
- styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
- HDs INT,
-
- wonWhenSeenStreet1 FLOAT,
- wonWhenSeenStreet2 FLOAT,
- wonWhenSeenStreet3 FLOAT,
- wonWhenSeenStreet4 FLOAT,
- wonAtSD FLOAT,
-
- street0VPI INT,
- street0Aggr INT,
- street0_3BChance INT,
- street0_3BDone INT,
- street0_4BChance INT,
- street0_4BDone INT,
- other3BStreet0 INT,
- other4BStreet0 INT,
-
- street1Seen INT,
- street2Seen INT,
- street3Seen INT,
- street4Seen INT,
- sawShowdown INT,
- street1Aggr INT,
- street2Aggr INT,
- street3Aggr INT,
- street4Aggr INT,
-
- otherRaisedStreet0 INT,
- otherRaisedStreet1 INT,
- otherRaisedStreet2 INT,
- otherRaisedStreet3 INT,
- otherRaisedStreet4 INT,
- foldToOtherRaisedStreet0 INT,
- foldToOtherRaisedStreet1 INT,
- foldToOtherRaisedStreet2 INT,
- foldToOtherRaisedStreet3 INT,
- foldToOtherRaisedStreet4 INT,
-
- stealAttemptChance INT,
- stealAttempted INT,
- foldBbToStealChance INT,
- foldedBbToSteal INT,
- foldSbToStealChance INT,
- foldedSbToSteal INT,
-
- street1CBChance INT,
- street1CBDone INT,
- street2CBChance INT,
- street2CBDone INT,
- street3CBChance INT,
- street3CBDone INT,
- street4CBChance INT,
- street4CBDone INT,
-
- foldToStreet1CBChance INT,
- foldToStreet1CBDone INT,
- foldToStreet2CBChance INT,
- foldToStreet2CBDone INT,
- foldToStreet3CBChance INT,
- foldToStreet3CBDone INT,
- foldToStreet4CBChance INT,
- foldToStreet4CBDone INT,
-
- totalProfit INT,
-
- street1CheckCallRaiseChance INT,
- street1CheckCallRaiseDone INT,
- street2CheckCallRaiseChance INT,
- street2CheckCallRaiseDone INT,
- street3CheckCallRaiseChance INT,
- street3CheckCallRaiseDone INT,
- street4CheckCallRaiseChance INT,
- street4CheckCallRaiseDone INT,
-
- street0Calls INT,
- street1Calls INT,
- street2Calls INT,
- street3Calls INT,
- street4Calls INT,
- street0Bets INT,
- street1Bets INT,
- street2Bets INT,
- street3Bets INT,
- street4Bets INT,
- street0Raises INT,
- street1Raises INT,
- street2Raises INT,
- street3Raises INT,
- street4Raises INT)
- """
- elif db_server == 'sqlite':
- self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
- id INTEGER PRIMARY KEY,
- gametypeId INT,
- playerId INT,
- activeSeats INT,
- position TEXT,
- tourneyTypeId INT DEFAULT 1,
- styleKey TEXT NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
- HDs INT,
-
- wonWhenSeenStreet1 REAL,
- wonWhenSeenStreet2 REAL,
- wonWhenSeenStreet3 REAL,
- wonWhenSeenStreet4 REAL,
- wonAtSD REAL,
-
- street0VPI INT,
- street0Aggr INT,
- street0_3BChance INT,
- street0_3BDone INT,
- street0_4BChance INT,
- street0_4BDone INT,
- other3BStreet0 INT,
- other4BStreet0 INT,
-
- street1Seen INT,
- street2Seen INT,
- street3Seen INT,
- street4Seen INT,
- sawShowdown INT,
- street1Aggr INT,
- street2Aggr INT,
- street3Aggr INT,
- street4Aggr INT,
-
- otherRaisedStreet0 INT,
- otherRaisedStreet1 INT,
- otherRaisedStreet2 INT,
- otherRaisedStreet3 INT,
- otherRaisedStreet4 INT,
- foldToOtherRaisedStreet0 INT,
- foldToOtherRaisedStreet1 INT,
- foldToOtherRaisedStreet2 INT,
- foldToOtherRaisedStreet3 INT,
- foldToOtherRaisedStreet4 INT,
-
- stealAttemptChance INT,
- stealAttempted INT,
- foldBbToStealChance INT,
- foldedBbToSteal INT,
- foldSbToStealChance INT,
- foldedSbToSteal INT,
-
- street1CBChance INT,
- street1CBDone INT,
- street2CBChance INT,
- street2CBDone INT,
- street3CBChance INT,
- street3CBDone INT,
- street4CBChance INT,
- street4CBDone INT,
-
- foldToStreet1CBChance INT,
- foldToStreet1CBDone INT,
- foldToStreet2CBChance INT,
- foldToStreet2CBDone INT,
- foldToStreet3CBChance INT,
- foldToStreet3CBDone INT,
- foldToStreet4CBChance INT,
- foldToStreet4CBDone INT,
-
- totalProfit INT,
-
- street1CheckCallRaiseChance INT,
- street1CheckCallRaiseDone INT,
- street2CheckCallRaiseChance INT,
- street2CheckCallRaiseDone INT,
- street3CheckCallRaiseChance INT,
- street3CheckCallRaiseDone INT,
- street4CheckCallRaiseChance INT,
- street4CheckCallRaiseDone INT,
-
- street0Calls INT,
- street1Calls INT,
- street2Calls INT,
- street3Calls INT,
- street4Calls INT,
- street0Bets INT,
- street1Bets INT,
- street2Bets INT,
- street3Bets INT,
- street4Bets INT,
- street0Raises INT,
- street1Raises INT,
- street2Raises INT,
- street3Raises INT,
- street4Raises INT)
- """
-
-
- if db_server == 'mysql':
- self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD UNIQUE INDEX siteTourneyNo(siteTourneyNo, tourneyTypeId)"""
- elif db_server == 'postgresql':
- self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
- elif db_server == 'sqlite':
- self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
-
- if db_server == 'mysql':
- self.query['addHandsIndex'] = """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gameTypeId)"""
- elif db_server == 'postgresql':
- self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)"""
- elif db_server == 'sqlite':
- self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)"""
-
- if db_server == 'mysql':
- self.query['addPlayersIndex'] = """ALTER TABLE Players ADD UNIQUE INDEX name(name, siteId)"""
- elif db_server == 'postgresql':
- self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
- elif db_server == 'sqlite':
- self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
-
- if db_server == 'mysql':
- self.query['addTPlayersIndex'] = """ALTER TABLE TourneysPlayers ADD UNIQUE INDEX tourneyId(tourneyId, playerId)"""
- elif db_server == 'postgresql':
- self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId)"""
- elif db_server == 'sqlite':
- self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId)"""
-
- if db_server == 'mysql':
- self.query['addTTypesIndex'] = """ALTER TABLE TourneyTypes ADD UNIQUE INDEX tourneytypes_all(buyin, fee
- , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
- elif db_server == 'postgresql':
- self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
- , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
- elif db_server == 'sqlite':
- self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
- , maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
-
- self.query['get_last_hand'] = "select max(id) from Hands"
-
- self.query['get_player_id'] = """
- select Players.id AS player_id
- from Players, Sites
- where Players.name = %s
- and Sites.name = %s
- and Players.siteId = Sites.id
- """
-
- self.query['get_player_names'] = """
- select p.name
- from Players p
- where lower(p.name) like lower(%s)
- and (p.siteId = %s or %s = -1)
- """
-
- self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
-
- self.query['get_stats_from_hand'] = """
- SELECT hc.playerId AS player_id,
- hp.seatNo AS seat,
- p.name AS screen_name,
- sum(hc.HDs) AS n,
- sum(hc.street0VPI) AS vpip,
- sum(hc.street0Aggr) AS pfr,
- sum(hc.street0_3BChance) AS TB_opp_0,
- sum(hc.street0_3BDone) AS TB_0,
- sum(hc.street1Seen) AS saw_f,
- sum(hc.street1Seen) AS saw_1,
- sum(hc.street2Seen) AS saw_2,
- sum(hc.street3Seen) AS saw_3,
- sum(hc.street4Seen) AS saw_4,
- sum(hc.sawShowdown) AS sd,
- sum(hc.street1Aggr) AS aggr_1,
- sum(hc.street2Aggr) AS aggr_2,
- sum(hc.street3Aggr) AS aggr_3,
- sum(hc.street4Aggr) AS aggr_4,
- sum(hc.otherRaisedStreet1) AS was_raised_1,
- sum(hc.otherRaisedStreet2) AS was_raised_2,
- sum(hc.otherRaisedStreet3) AS was_raised_3,
- sum(hc.otherRaisedStreet4) AS was_raised_4,
- sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
- sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
- sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
- sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
- sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
- sum(hc.wonAtSD) AS wmsd,
- sum(hc.stealAttemptChance) AS steal_opp,
- sum(hc.stealAttempted) AS steal,
- sum(hc.foldSbToStealChance) AS SBstolen,
- sum(hc.foldedSbToSteal) AS SBnotDef,
- sum(hc.foldBbToStealChance) AS BBstolen,
- sum(hc.foldedBbToSteal) AS BBnotDef,
- sum(hc.street1CBChance) AS CB_opp_1,
- sum(hc.street1CBDone) AS CB_1,
- sum(hc.street2CBChance) AS CB_opp_2,
- sum(hc.street2CBDone) AS CB_2,
- sum(hc.street3CBChance) AS CB_opp_3,
- sum(hc.street3CBDone) AS CB_3,
- sum(hc.street4CBChance) AS CB_opp_4,
- sum(hc.street4CBDone) AS CB_4,
- sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
- sum(hc.foldToStreet1CBDone) AS f_cb_1,
- sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
- sum(hc.foldToStreet2CBDone) AS f_cb_2,
- sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
- sum(hc.foldToStreet3CBDone) AS f_cb_3,
- sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
- sum(hc.foldToStreet4CBDone) AS f_cb_4,
- sum(hc.totalProfit) AS net,
- sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
- sum(hc.street1CheckCallRaiseDone) AS ccr_1,
- sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
- sum(hc.street2CheckCallRaiseDone) AS ccr_2,
- sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
- sum(hc.street3CheckCallRaiseDone) AS ccr_3,
- sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
- sum(hc.street4CheckCallRaiseDone) AS ccr_4
- FROM Hands h
- INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
- INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0
- AND hc.gametypeId+0 = h.gametypeId+0)
- INNER JOIN Players p ON (p.id = hp.PlayerId+0)
- WHERE h.id = %s
- AND hc.styleKey > %s
- /* styleKey is currently 'd' (for date) followed by a yyyymmdd
- date key. Set it to 0000000 or similar to get all records */
- /* also check activeseats here even if only 3 groups eg 2-3/4-6/7+
- e.g. could use a multiplier:
- AND h.seats > X / 1.25 and hp.seats < X * 1.25
- where X is the number of active players at the current table (and
- 1.25 would be a config value so user could change it)
- */
- GROUP BY hc.PlayerId, hp.seatNo, p.name
- """
+ self.query['get_stats_from_hand'] = """
+ SELECT hc.playerId AS player_id,
+ hp.seatNo AS seat,
+ p.name AS screen_name,
+ sum(hc.HDs) AS n,
+ sum(hc.street0VPI) AS vpip,
+ sum(hc.street0Aggr) AS pfr,
+ sum(hc.street0_3BChance) AS TB_opp_0,
+ sum(hc.street0_3BDone) AS TB_0,
+ sum(hc.street1Seen) AS saw_f,
+ sum(hc.street1Seen) AS saw_1,
+ sum(hc.street2Seen) AS saw_2,
+ sum(hc.street3Seen) AS saw_3,
+ sum(hc.street4Seen) AS saw_4,
+ sum(hc.sawShowdown) AS sd,
+ sum(hc.street1Aggr) AS aggr_1,
+ sum(hc.street2Aggr) AS aggr_2,
+ sum(hc.street3Aggr) AS aggr_3,
+ sum(hc.street4Aggr) AS aggr_4,
+ sum(hc.otherRaisedStreet1) AS was_raised_1,
+ sum(hc.otherRaisedStreet2) AS was_raised_2,
+ sum(hc.otherRaisedStreet3) AS was_raised_3,
+ sum(hc.otherRaisedStreet4) AS was_raised_4,
+ sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
+ sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
+ sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
+ sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
+ sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
+ sum(hc.wonAtSD) AS wmsd,
+ sum(hc.stealAttemptChance) AS steal_opp,
+ sum(hc.stealAttempted) AS steal,
+ sum(hc.foldSbToStealChance) AS SBstolen,
+ sum(hc.foldedSbToSteal) AS SBnotDef,
+ sum(hc.foldBbToStealChance) AS BBstolen,
+ sum(hc.foldedBbToSteal) AS BBnotDef,
+ sum(hc.street1CBChance) AS CB_opp_1,
+ sum(hc.street1CBDone) AS CB_1,
+ sum(hc.street2CBChance) AS CB_opp_2,
+ sum(hc.street2CBDone) AS CB_2,
+ sum(hc.street3CBChance) AS CB_opp_3,
+ sum(hc.street3CBDone) AS CB_3,
+ sum(hc.street4CBChance) AS CB_opp_4,
+ sum(hc.street4CBDone) AS CB_4,
+ sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
+ sum(hc.foldToStreet1CBDone) AS f_cb_1,
+ sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
+ sum(hc.foldToStreet2CBDone) AS f_cb_2,
+ sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
+ sum(hc.foldToStreet3CBDone) AS f_cb_3,
+ sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
+ sum(hc.foldToStreet4CBDone) AS f_cb_4,
+ sum(hc.totalProfit) AS net,
+ sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
+ sum(hc.street1CheckCallRaiseDone) AS ccr_1,
+ sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
+ sum(hc.street2CheckCallRaiseDone) AS ccr_2,
+ sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
+ sum(hc.street3CheckCallRaiseDone) AS ccr_3,
+ sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
+ sum(hc.street4CheckCallRaiseDone) AS ccr_4
+ FROM Hands h
+ INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
+ INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0
+ AND hc.gametypeId+0 = h.gametypeId+0)
+ INNER JOIN Players p ON (p.id = hp.PlayerId+0)
+ WHERE h.id = %s
+ AND hc.styleKey > %s
+ /* styleKey is currently 'd' (for date) followed by a yyyymmdd
+ date key. Set it to 0000000 or similar to get all records */
+ /* also check activeseats here even if only 3 groups eg 2-3/4-6/7+
+ e.g. could use a multiplier:
+ AND h.seats > X / 1.25 and hp.seats < X * 1.25
+ where X is the number of active players at the current table (and
+ 1.25 would be a config value so user could change it)
+ */
+ GROUP BY hc.PlayerId, hp.seatNo, p.name
+ """
# same as above except stats are aggregated for all blind/limit levels
- self.query['get_stats_from_hand_aggregated'] = """
- SELECT hc.playerId AS player_id,
- max(case when hc.gametypeId = h.gametypeId
- then hp.seatNo
- else -1
- end) AS seat,
- p.name AS screen_name,
- sum(hc.HDs) AS n,
- sum(hc.street0VPI) AS vpip,
- sum(hc.street0Aggr) AS pfr,
- sum(hc.street0_3BChance) AS TB_opp_0,
- sum(hc.street0_3BDone) AS TB_0,
- sum(hc.street1Seen) AS saw_f,
- sum(hc.street1Seen) AS saw_1,
- sum(hc.street2Seen) AS saw_2,
- sum(hc.street3Seen) AS saw_3,
- sum(hc.street4Seen) AS saw_4,
- sum(hc.sawShowdown) AS sd,
- sum(hc.street1Aggr) AS aggr_1,
- sum(hc.street2Aggr) AS aggr_2,
- sum(hc.street3Aggr) AS aggr_3,
- sum(hc.street4Aggr) AS aggr_4,
- sum(hc.otherRaisedStreet1) AS was_raised_1,
- sum(hc.otherRaisedStreet2) AS was_raised_2,
- sum(hc.otherRaisedStreet3) AS was_raised_3,
- sum(hc.otherRaisedStreet4) AS was_raised_4,
- sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
- sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
- sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
- sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
- sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
- sum(hc.wonAtSD) AS wmsd,
- sum(hc.stealAttemptChance) AS steal_opp,
- sum(hc.stealAttempted) AS steal,
- sum(hc.foldSbToStealChance) AS SBstolen,
- sum(hc.foldedSbToSteal) AS SBnotDef,
- sum(hc.foldBbToStealChance) AS BBstolen,
- sum(hc.foldedBbToSteal) AS BBnotDef,
- sum(hc.street1CBChance) AS CB_opp_1,
- sum(hc.street1CBDone) AS CB_1,
- sum(hc.street2CBChance) AS CB_opp_2,
- sum(hc.street2CBDone) AS CB_2,
- sum(hc.street3CBChance) AS CB_opp_3,
- sum(hc.street3CBDone) AS CB_3,
- sum(hc.street4CBChance) AS CB_opp_4,
- sum(hc.street4CBDone) AS CB_4,
- sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
- sum(hc.foldToStreet1CBDone) AS f_cb_1,
- sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
- sum(hc.foldToStreet2CBDone) AS f_cb_2,
- sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
- sum(hc.foldToStreet3CBDone) AS f_cb_3,
- sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
- sum(hc.foldToStreet4CBDone) AS f_cb_4,
- sum(hc.totalProfit) AS net,
- sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
- sum(hc.street1CheckCallRaiseDone) AS ccr_1,
- sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
- sum(hc.street2CheckCallRaiseDone) AS ccr_2,
- sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
- sum(hc.street3CheckCallRaiseDone) AS ccr_3,
- sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
- sum(hc.street4CheckCallRaiseDone) AS ccr_4
- FROM Hands h
- INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
- INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
- INNER JOIN Players p ON (p.id = hc.playerId)
- WHERE h.id = %s
- AND ( /* 2 separate parts for hero and opponents */
- ( hp.playerId != %s
- AND hc.styleKey > %s
- AND hc.gametypeId+0 in
- (SELECT gt1.id from Gametypes gt1, Gametypes gt2
- WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
- AND gt1.type = gt2.type /* ring/tourney */
- AND gt1.category = gt2.category /* holdem/stud*/
- AND gt1.limittype = gt2.limittype /* fl/nl */
- AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
- AND gt1.bigblind >= gt2.bigblind / %s
- AND gt2.id = h.gametypeId)
- )
- OR
- ( hp.playerId = %s
- AND hc.styleKey > %s
- AND hc.gametypeId+0 in
- (SELECT gt1.id from Gametypes gt1, Gametypes gt2
- WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
- AND gt1.type = gt2.type /* ring/tourney */
- AND gt1.category = gt2.category /* holdem/stud*/
- AND gt1.limittype = gt2.limittype /* fl/nl */
- AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
- AND gt1.bigblind >= gt2.bigblind / %s
- AND gt2.id = h.gametypeId)
- )
+ self.query['get_stats_from_hand_aggregated'] = """
+ SELECT hc.playerId AS player_id,
+ max(case when hc.gametypeId = h.gametypeId
+ then hp.seatNo
+ else -1
+ end) AS seat,
+ p.name AS screen_name,
+ sum(hc.HDs) AS n,
+ sum(hc.street0VPI) AS vpip,
+ sum(hc.street0Aggr) AS pfr,
+ sum(hc.street0_3BChance) AS TB_opp_0,
+ sum(hc.street0_3BDone) AS TB_0,
+ sum(hc.street1Seen) AS saw_f,
+ sum(hc.street1Seen) AS saw_1,
+ sum(hc.street2Seen) AS saw_2,
+ sum(hc.street3Seen) AS saw_3,
+ sum(hc.street4Seen) AS saw_4,
+ sum(hc.sawShowdown) AS sd,
+ sum(hc.street1Aggr) AS aggr_1,
+ sum(hc.street2Aggr) AS aggr_2,
+ sum(hc.street3Aggr) AS aggr_3,
+ sum(hc.street4Aggr) AS aggr_4,
+ sum(hc.otherRaisedStreet1) AS was_raised_1,
+ sum(hc.otherRaisedStreet2) AS was_raised_2,
+ sum(hc.otherRaisedStreet3) AS was_raised_3,
+ sum(hc.otherRaisedStreet4) AS was_raised_4,
+ sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
+ sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
+ sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
+ sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
+ sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
+ sum(hc.wonAtSD) AS wmsd,
+ sum(hc.stealAttemptChance) AS steal_opp,
+ sum(hc.stealAttempted) AS steal,
+ sum(hc.foldSbToStealChance) AS SBstolen,
+ sum(hc.foldedSbToSteal) AS SBnotDef,
+ sum(hc.foldBbToStealChance) AS BBstolen,
+ sum(hc.foldedBbToSteal) AS BBnotDef,
+ sum(hc.street1CBChance) AS CB_opp_1,
+ sum(hc.street1CBDone) AS CB_1,
+ sum(hc.street2CBChance) AS CB_opp_2,
+ sum(hc.street2CBDone) AS CB_2,
+ sum(hc.street3CBChance) AS CB_opp_3,
+ sum(hc.street3CBDone) AS CB_3,
+ sum(hc.street4CBChance) AS CB_opp_4,
+ sum(hc.street4CBDone) AS CB_4,
+ sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
+ sum(hc.foldToStreet1CBDone) AS f_cb_1,
+ sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
+ sum(hc.foldToStreet2CBDone) AS f_cb_2,
+ sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
+ sum(hc.foldToStreet3CBDone) AS f_cb_3,
+ sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
+ sum(hc.foldToStreet4CBDone) AS f_cb_4,
+ sum(hc.totalProfit) AS net,
+ sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
+ sum(hc.street1CheckCallRaiseDone) AS ccr_1,
+ sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
+ sum(hc.street2CheckCallRaiseDone) AS ccr_2,
+ sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
+ sum(hc.street3CheckCallRaiseDone) AS ccr_3,
+ sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
+ sum(hc.street4CheckCallRaiseDone) AS ccr_4
+ FROM Hands h
+ INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
+ INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
+ INNER JOIN Players p ON (p.id = hc.playerId)
+ WHERE h.id = %s
+ AND ( /* 2 separate parts for hero and opponents */
+ ( hp.playerId != %s
+ AND hc.styleKey > %s
+ AND hc.gametypeId+0 in
+ (SELECT gt1.id from Gametypes gt1, Gametypes gt2
+ WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
+ AND gt1.type = gt2.type /* ring/tourney */
+ AND gt1.category = gt2.category /* holdem/stud*/
+ AND gt1.limittype = gt2.limittype /* fl/nl */
+ AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
+ AND gt1.bigblind >= gt2.bigblind / %s
+ AND gt2.id = h.gametypeId)
)
- GROUP BY hc.PlayerId, p.name
- """
- # NOTES on above cursor:
- # - Do NOT include %s inside query in a comment - the db api thinks
- # they are actual arguments.
- # - styleKey is currently 'd' (for date) followed by a yyyymmdd
- # date key. Set it to 0000000 or similar to get all records
- # Could also check activeseats here even if only 3 groups eg 2-3/4-6/7+
- # e.g. could use a multiplier:
- # AND h.seats > %s / 1.25 and hp.seats < %s * 1.25
- # where %s is the number of active players at the current table (and
- # 1.25 would be a config value so user could change it)
+ OR
+ ( hp.playerId = %s
+ AND hc.styleKey > %s
+ AND hc.gametypeId+0 in
+ (SELECT gt1.id from Gametypes gt1, Gametypes gt2
+ WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
+ AND gt1.type = gt2.type /* ring/tourney */
+ AND gt1.category = gt2.category /* holdem/stud*/
+ AND gt1.limittype = gt2.limittype /* fl/nl */
+ AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
+ AND gt1.bigblind >= gt2.bigblind / %s
+ AND gt2.id = h.gametypeId)
+ )
+ )
+ GROUP BY hc.PlayerId, p.name
+ """
+ # NOTES on above cursor:
+ # - Do NOT include %s inside query in a comment - the db api thinks
+ # they are actual arguments.
+ # - styleKey is currently 'd' (for date) followed by a yyyymmdd
+ # date key. Set it to 0000000 or similar to get all records
+ # Could also check activeseats here even if only 3 groups eg 2-3/4-6/7+
+ # e.g. could use a multiplier:
+ # AND h.seats > %s / 1.25 and hp.seats < %s * 1.25
+ # where %s is the number of active players at the current table (and
+ # 1.25 would be a config value so user could change it)
- if db_server == 'mysql':
- self.query['get_stats_from_hand_session'] = """
- SELECT hp.playerId AS player_id,
- hp.handId AS hand_id,
- hp.seatNo AS seat,
- p.name AS screen_name,
- h.seats AS seats,
- 1 AS n,
- cast(hp2.street0VPI as integer) AS vpip,
- cast(hp2.street0Aggr as integer) AS pfr,
- cast(hp2.street0_3BChance as integer) AS TB_opp_0,
- cast(hp2.street0_3BDone as integer) AS TB_0,
- cast(hp2.street1Seen as integer) AS saw_f,
- cast(hp2.street1Seen as integer) AS saw_1,
- cast(hp2.street2Seen as integer) AS saw_2,
- cast(hp2.street3Seen as integer) AS saw_3,
- cast(hp2.street4Seen as integer) AS saw_4,
- cast(hp2.sawShowdown as integer) AS sd,
- cast(hp2.street1Aggr as integer) AS aggr_1,
- cast(hp2.street2Aggr as integer) AS aggr_2,
- cast(hp2.street3Aggr as integer) AS aggr_3,
- cast(hp2.street4Aggr as integer) AS aggr_4,
- cast(hp2.otherRaisedStreet1 as integer) AS was_raised_1,
- cast(hp2.otherRaisedStreet2 as integer) AS was_raised_2,
- cast(hp2.otherRaisedStreet3 as integer) AS was_raised_3,
- cast(hp2.otherRaisedStreet4 as integer) AS was_raised_4,
- cast(hp2.foldToOtherRaisedStreet1 as integer) AS f_freq_1,
- cast(hp2.foldToOtherRaisedStreet2 as integer) AS f_freq_2,
- cast(hp2.foldToOtherRaisedStreet3 as integer) AS f_freq_3,
- cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4,
- cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1,
- cast(hp2.wonAtSD as integer) AS wmsd,
- cast(hp2.stealAttemptChance as integer) AS steal_opp,
- cast(hp2.stealAttempted as integer) AS steal,
- cast(hp2.foldSbToStealChance as integer) AS SBstolen,
- cast(hp2.foldedSbToSteal as integer) AS SBnotDef,
- cast(hp2.foldBbToStealChance as integer) AS BBstolen,
- cast(hp2.foldedBbToSteal as integer) AS BBnotDef,
- cast(hp2.street1CBChance as integer) AS CB_opp_1,
- cast(hp2.street1CBDone as integer) AS CB_1,
- cast(hp2.street2CBChance as integer) AS CB_opp_2,
- cast(hp2.street2CBDone as integer) AS CB_2,
- cast(hp2.street3CBChance as integer) AS CB_opp_3,
- cast(hp2.street3CBDone as integer) AS CB_3,
- cast(hp2.street4CBChance as integer) AS CB_opp_4,
- cast(hp2.street4CBDone as integer) AS CB_4,
- cast(hp2.foldToStreet1CBChance as integer) AS f_cb_opp_1,
- cast(hp2.foldToStreet1CBDone as integer) AS f_cb_1,
- cast(hp2.foldToStreet2CBChance as integer) AS f_cb_opp_2,
- cast(hp2.foldToStreet2CBDone as integer) AS f_cb_2,
- cast(hp2.foldToStreet3CBChance as integer) AS f_cb_opp_3,
- cast(hp2.foldToStreet3CBDone as integer) AS f_cb_3,
- cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
- cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
- cast(hp2.totalProfit as integer) AS net,
- cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
- cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
- cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
- cast(hp2.street2CheckCallRaiseDone as integer) AS ccr_2,
- cast(hp2.street3CheckCallRaiseChance as integer) AS ccr_opp_3,
- cast(hp2.street3CheckCallRaiseDone as integer) AS ccr_3,
- cast(hp2.street4CheckCallRaiseChance as integer) AS ccr_opp_4,
- cast(hp2.street4CheckCallRaiseDone as integer) AS ccr_4
- FROM
- Hands h /* players in this hand */
- INNER JOIN Hands h2 ON (h2.id > %s AND h2.tableName = h.tableName)
- INNER JOIN HandsPlayers hp ON (h.id = hp.handId)
- INNER JOIN HandsPlayers hp2 ON (hp2.playerId+0 = hp.playerId+0 AND (hp2.handId = h2.id+0)) /* other hands by these players */
- INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
- WHERE hp.handId = %s
- /* check activeseats once this data returned (don't want to do that here as it might
- assume a session ended just because the number of seats dipped for a few hands)
- */
- ORDER BY h.handStart desc, hp2.PlayerId
- /* order rows by handstart descending so that we can stop reading rows when
- there's a gap over X minutes between hands (ie. when we get back to start of
- the session */
- """
- else: # assume postgresql
- self.query['get_stats_from_hand_session'] = """
- SELECT hp.playerId AS player_id,
- hp.handId AS hand_id,
- hp.seatNo AS seat,
- p.name AS screen_name,
- h.seats AS seats,
- 1 AS n,
- cast(hp2.street0VPI as integer) AS vpip,
- cast(hp2.street0Aggr as integer) AS pfr,
- cast(hp2.street0_3BChance as integer) AS TB_opp_0,
- cast(hp2.street0_3BDone as integer) AS TB_0,
- cast(hp2.street1Seen as integer) AS saw_f,
- cast(hp2.street1Seen as integer) AS saw_1,
- cast(hp2.street2Seen as integer) AS saw_2,
- cast(hp2.street3Seen as integer) AS saw_3,
- cast(hp2.street4Seen as integer) AS saw_4,
- cast(hp2.sawShowdown as integer) AS sd,
- cast(hp2.street1Aggr as integer) AS aggr_1,
- cast(hp2.street2Aggr as integer) AS aggr_2,
- cast(hp2.street3Aggr as integer) AS aggr_3,
- cast(hp2.street4Aggr as integer) AS aggr_4,
- cast(hp2.otherRaisedStreet1 as integer) AS was_raised_1,
- cast(hp2.otherRaisedStreet2 as integer) AS was_raised_2,
- cast(hp2.otherRaisedStreet3 as integer) AS was_raised_3,
- cast(hp2.otherRaisedStreet4 as integer) AS was_raised_4,
- cast(hp2.foldToOtherRaisedStreet1 as integer) AS f_freq_1,
- cast(hp2.foldToOtherRaisedStreet2 as integer) AS f_freq_2,
- cast(hp2.foldToOtherRaisedStreet3 as integer) AS f_freq_3,
- cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4,
- cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1,
- cast(hp2.wonAtSD as integer) AS wmsd,
- cast(hp2.stealAttemptChance as integer) AS steal_opp,
- cast(hp2.stealAttempted as integer) AS steal,
- cast(hp2.foldSbToStealChance as integer) AS SBstolen,
- cast(hp2.foldedSbToSteal as integer) AS SBnotDef,
- cast(hp2.foldBbToStealChance as integer) AS BBstolen,
- cast(hp2.foldedBbToSteal as integer) AS BBnotDef,
- cast(hp2.street1CBChance as integer) AS CB_opp_1,
- cast(hp2.street1CBDone as integer) AS CB_1,
- cast(hp2.street2CBChance as integer) AS CB_opp_2,
- cast(hp2.street2CBDone as integer) AS CB_2,
- cast(hp2.street3CBChance as integer) AS CB_opp_3,
- cast(hp2.street3CBDone as integer) AS CB_3,
- cast(hp2.street4CBChance as integer) AS CB_opp_4,
- cast(hp2.street4CBDone as integer) AS CB_4,
- cast(hp2.foldToStreet1CBChance as integer) AS f_cb_opp_1,
- cast(hp2.foldToStreet1CBDone as integer) AS f_cb_1,
- cast(hp2.foldToStreet2CBChance as integer) AS f_cb_opp_2,
- cast(hp2.foldToStreet2CBDone as integer) AS f_cb_2,
- cast(hp2.foldToStreet3CBChance as integer) AS f_cb_opp_3,
- cast(hp2.foldToStreet3CBDone as integer) AS f_cb_3,
- cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
- cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
- cast(hp2.totalProfit as integer) AS net,
- cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
- cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
- cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
- cast(hp2.street2CheckCallRaiseDone as integer) AS ccr_2,
- cast(hp2.street3CheckCallRaiseChance as integer) AS ccr_opp_3,
- cast(hp2.street3CheckCallRaiseDone as integer) AS ccr_3,
- cast(hp2.street4CheckCallRaiseChance as integer) AS ccr_opp_4,
- cast(hp2.street4CheckCallRaiseDone as integer) AS ccr_4
- FROM Hands h /* this hand */
- INNER JOIN Hands h2 ON ( h2.id > %s /* other hands */
- AND h2.tableName = h.tableName)
- INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
- INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
- AND hp2.handId = h2.id) /* other hands by these players */
- INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
- WHERE h.id = %s
- /* check activeseats once this data returned (don't want to do that here as it might
- assume a session ended just because the number of seats dipped for a few hands)
- */
- ORDER BY h.handStart desc, hp2.PlayerId
- /* order rows by handstart descending so that we can stop reading rows when
- there's a gap over X minutes between hands (ie. when we get back to start of
- the session */
- """
-
- self.query['get_players_from_hand'] = """
- SELECT HandsPlayers.playerId, seatNo, name
- FROM HandsPlayers INNER JOIN Players ON (HandsPlayers.playerId = Players.id)
- WHERE handId = %s
+ if db_server == 'mysql':
+ self.query['get_stats_from_hand_session'] = """
+ SELECT hp.playerId AS player_id,
+ hp.handId AS hand_id,
+ hp.seatNo AS seat,
+ p.name AS screen_name,
+ h.seats AS seats,
+ 1 AS n,
+ cast(hp2.street0VPI as integer) AS vpip,
+ cast(hp2.street0Aggr as integer) AS pfr,
+ cast(hp2.street0_3BChance as integer) AS TB_opp_0,
+ cast(hp2.street0_3BDone as integer) AS TB_0,
+ cast(hp2.street1Seen as integer) AS saw_f,
+ cast(hp2.street1Seen as integer) AS saw_1,
+ cast(hp2.street2Seen as integer) AS saw_2,
+ cast(hp2.street3Seen as integer) AS saw_3,
+ cast(hp2.street4Seen as integer) AS saw_4,
+ cast(hp2.sawShowdown as integer) AS sd,
+ cast(hp2.street1Aggr as integer) AS aggr_1,
+ cast(hp2.street2Aggr as integer) AS aggr_2,
+ cast(hp2.street3Aggr as integer) AS aggr_3,
+ cast(hp2.street4Aggr as integer) AS aggr_4,
+ cast(hp2.otherRaisedStreet1 as integer) AS was_raised_1,
+ cast(hp2.otherRaisedStreet2 as integer) AS was_raised_2,
+ cast(hp2.otherRaisedStreet3 as integer) AS was_raised_3,
+ cast(hp2.otherRaisedStreet4 as integer) AS was_raised_4,
+ cast(hp2.foldToOtherRaisedStreet1 as integer) AS f_freq_1,
+ cast(hp2.foldToOtherRaisedStreet2 as integer) AS f_freq_2,
+ cast(hp2.foldToOtherRaisedStreet3 as integer) AS f_freq_3,
+ cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4,
+ cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1,
+ cast(hp2.wonAtSD as integer) AS wmsd,
+ cast(hp2.stealAttemptChance as integer) AS steal_opp,
+ cast(hp2.stealAttempted as integer) AS steal,
+ cast(hp2.foldSbToStealChance as integer) AS SBstolen,
+ cast(hp2.foldedSbToSteal as integer) AS SBnotDef,
+ cast(hp2.foldBbToStealChance as integer) AS BBstolen,
+ cast(hp2.foldedBbToSteal as integer) AS BBnotDef,
+ cast(hp2.street1CBChance as integer) AS CB_opp_1,
+ cast(hp2.street1CBDone as integer) AS CB_1,
+ cast(hp2.street2CBChance as integer) AS CB_opp_2,
+ cast(hp2.street2CBDone as integer) AS CB_2,
+ cast(hp2.street3CBChance as integer) AS CB_opp_3,
+ cast(hp2.street3CBDone as integer) AS CB_3,
+ cast(hp2.street4CBChance as integer) AS CB_opp_4,
+ cast(hp2.street4CBDone as integer) AS CB_4,
+ cast(hp2.foldToStreet1CBChance as integer) AS f_cb_opp_1,
+ cast(hp2.foldToStreet1CBDone as integer) AS f_cb_1,
+ cast(hp2.foldToStreet2CBChance as integer) AS f_cb_opp_2,
+ cast(hp2.foldToStreet2CBDone as integer) AS f_cb_2,
+ cast(hp2.foldToStreet3CBChance as integer) AS f_cb_opp_3,
+ cast(hp2.foldToStreet3CBDone as integer) AS f_cb_3,
+ cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
+ cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
+ cast(hp2.totalProfit as integer) AS net,
+ cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
+ cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
+ cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
+ cast(hp2.street2CheckCallRaiseDone as integer) AS ccr_2,
+ cast(hp2.street3CheckCallRaiseChance as integer) AS ccr_opp_3,
+ cast(hp2.street3CheckCallRaiseDone as integer) AS ccr_3,
+ cast(hp2.street4CheckCallRaiseChance as integer) AS ccr_opp_4,
+ cast(hp2.street4CheckCallRaiseDone as integer) AS ccr_4
+ FROM
+ Hands h /* players in this hand */
+ INNER JOIN Hands h2 ON (h2.id > %s AND h2.tableName = h.tableName)
+ INNER JOIN HandsPlayers hp ON (h.id = hp.handId)
+ INNER JOIN HandsPlayers hp2 ON (hp2.playerId+0 = hp.playerId+0 AND (hp2.handId = h2.id+0)) /* other hands by these players */
+ INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
+ WHERE hp.handId = %s
+ /* check activeseats once this data returned (don't want to do that here as it might
+ assume a session ended just because the number of seats dipped for a few hands)
+ */
+ ORDER BY h.handStart desc, hp2.PlayerId
+ /* order rows by handstart descending so that we can stop reading rows when
+ there's a gap over X minutes between hands (ie. when we get back to start of
+ the session */
"""
+ else: # assume postgresql
+ self.query['get_stats_from_hand_session'] = """
+ SELECT hp.playerId AS player_id,
+ hp.handId AS hand_id,
+ hp.seatNo AS seat,
+ p.name AS screen_name,
+ h.seats AS seats,
+ 1 AS n,
+ cast(hp2.street0VPI as integer) AS vpip,
+ cast(hp2.street0Aggr as integer) AS pfr,
+ cast(hp2.street0_3BChance as integer) AS TB_opp_0,
+ cast(hp2.street0_3BDone as integer) AS TB_0,
+ cast(hp2.street1Seen as integer) AS saw_f,
+ cast(hp2.street1Seen as integer) AS saw_1,
+ cast(hp2.street2Seen as integer) AS saw_2,
+ cast(hp2.street3Seen as integer) AS saw_3,
+ cast(hp2.street4Seen as integer) AS saw_4,
+ cast(hp2.sawShowdown as integer) AS sd,
+ cast(hp2.street1Aggr as integer) AS aggr_1,
+ cast(hp2.street2Aggr as integer) AS aggr_2,
+ cast(hp2.street3Aggr as integer) AS aggr_3,
+ cast(hp2.street4Aggr as integer) AS aggr_4,
+ cast(hp2.otherRaisedStreet1 as integer) AS was_raised_1,
+ cast(hp2.otherRaisedStreet2 as integer) AS was_raised_2,
+ cast(hp2.otherRaisedStreet3 as integer) AS was_raised_3,
+ cast(hp2.otherRaisedStreet4 as integer) AS was_raised_4,
+ cast(hp2.foldToOtherRaisedStreet1 as integer) AS f_freq_1,
+ cast(hp2.foldToOtherRaisedStreet2 as integer) AS f_freq_2,
+ cast(hp2.foldToOtherRaisedStreet3 as integer) AS f_freq_3,
+ cast(hp2.foldToOtherRaisedStreet4 as integer) AS f_freq_4,
+ cast(hp2.wonWhenSeenStreet1 as integer) AS w_w_s_1,
+ cast(hp2.wonAtSD as integer) AS wmsd,
+ cast(hp2.stealAttemptChance as integer) AS steal_opp,
+ cast(hp2.stealAttempted as integer) AS steal,
+ cast(hp2.foldSbToStealChance as integer) AS SBstolen,
+ cast(hp2.foldedSbToSteal as integer) AS SBnotDef,
+ cast(hp2.foldBbToStealChance as integer) AS BBstolen,
+ cast(hp2.foldedBbToSteal as integer) AS BBnotDef,
+ cast(hp2.street1CBChance as integer) AS CB_opp_1,
+ cast(hp2.street1CBDone as integer) AS CB_1,
+ cast(hp2.street2CBChance as integer) AS CB_opp_2,
+ cast(hp2.street2CBDone as integer) AS CB_2,
+ cast(hp2.street3CBChance as integer) AS CB_opp_3,
+ cast(hp2.street3CBDone as integer) AS CB_3,
+ cast(hp2.street4CBChance as integer) AS CB_opp_4,
+ cast(hp2.street4CBDone as integer) AS CB_4,
+ cast(hp2.foldToStreet1CBChance as integer) AS f_cb_opp_1,
+ cast(hp2.foldToStreet1CBDone as integer) AS f_cb_1,
+ cast(hp2.foldToStreet2CBChance as integer) AS f_cb_opp_2,
+ cast(hp2.foldToStreet2CBDone as integer) AS f_cb_2,
+ cast(hp2.foldToStreet3CBChance as integer) AS f_cb_opp_3,
+ cast(hp2.foldToStreet3CBDone as integer) AS f_cb_3,
+ cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
+ cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
+ cast(hp2.totalProfit as integer) AS net,
+ cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
+ cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
+ cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
+ cast(hp2.street2CheckCallRaiseDone as integer) AS ccr_2,
+ cast(hp2.street3CheckCallRaiseChance as integer) AS ccr_opp_3,
+ cast(hp2.street3CheckCallRaiseDone as integer) AS ccr_3,
+ cast(hp2.street4CheckCallRaiseChance as integer) AS ccr_opp_4,
+ cast(hp2.street4CheckCallRaiseDone as integer) AS ccr_4
+ FROM Hands h /* this hand */
+ INNER JOIN Hands h2 ON ( h2.id > %s /* other hands */
+ AND h2.tableName = h.tableName)
+ INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
+ INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
+ AND hp2.handId = h2.id) /* other hands by these players */
+ INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
+ WHERE h.id = %s
+ /* check activeseats once this data returned (don't want to do that here as it might
+ assume a session ended just because the number of seats dipped for a few hands)
+ */
+ ORDER BY h.handStart desc, hp2.PlayerId
+ /* order rows by handstart descending so that we can stop reading rows when
+ there's a gap over X minutes between hands (ie. when we get back to start of
+ the session */
+ """
+
+ self.query['get_players_from_hand'] = """
+ SELECT HandsPlayers.playerId, seatNo, name
+ FROM HandsPlayers INNER JOIN Players ON (HandsPlayers.playerId = Players.id)
+ WHERE handId = %s
+ """
# WHERE handId = %s AND Players.id LIKE %s
- self.query['get_winners_from_hand'] = """
- SELECT name, winnings
- FROM HandsPlayers, Players
- WHERE winnings > 0
- AND Players.id = HandsPlayers.playerId
- AND handId = %s;
- """
-
- self.query['get_table_name'] = """
- select h.tableName, h.maxSeats, gt.category, gt.type, gt.siteId
- from Hands h
- ,Gametypes gt
- where h.id = %s
- and gt.id = h.gametypeId
- """
-
- self.query['get_actual_seat'] = """
- select seatNo
- from HandsPlayers
- where HandsPlayers.handId = %s
- and HandsPlayers.playerId = (select Players.id from Players
- where Players.name = %s)
- """
-
- self.query['get_cards'] = """
- select
- seatNo AS seat_number,
- card1, /*card1Value, card1Suit, */
- card2, /*card2Value, card2Suit, */
- card3, /*card3Value, card3Suit, */
- card4, /*card4Value, card4Suit, */
- card5, /*card5Value, card5Suit, */
- card6, /*card6Value, card6Suit, */
- card7 /*card7Value, card7Suit */
- from HandsPlayers, Players
- where handID = %s and HandsPlayers.playerId = Players.id
- order by seatNo
- """
-
- self.query['get_common_cards'] = """
- select
- boardcard1,
- boardcard2,
- boardcard3,
- boardcard4,
- boardcard5
- from Hands
- where Id = %s
- """
-
- self.query['get_action_from_hand'] = """
- SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
- FROM Players, HandsActions, HandsPlayers
- WHERE HandsPlayers.handid = %s
- AND HandsPlayers.playerid = Players.id
- AND HandsActions.handsPlayerId = HandsPlayers.id
- ORDER BY street, actionno
+ self.query['get_winners_from_hand'] = """
+ SELECT name, winnings
+ FROM HandsPlayers, Players
+ WHERE winnings > 0
+ AND Players.id = HandsPlayers.playerId
+ AND handId = %s;
"""
- if db_server == 'mysql':
- self.query['get_hand_1day_ago'] = """
- select coalesce(max(id),0)
- from Hands
- where handStart < date_sub(utc_timestamp(), interval '1' day)"""
- elif db_server == 'postgresql':
- self.query['get_hand_1day_ago'] = """
- select coalesce(max(id),0)
- from Hands
- where handStart < now() at time zone 'UTC' - interval '1 day'"""
- elif db_server == 'sqlite':
- self.query['get_hand_1day_ago'] = """
- select coalesce(max(id),0)
- from Hands
- where handStart < strftime('%J', 'now') - 1"""
+ self.query['get_table_name'] = """
+ select h.tableName, h.maxSeats, gt.category, gt.type, gt.siteId
+ from Hands h
+ ,Gametypes gt
+ where h.id = %s
+ and gt.id = h.gametypeId
+ """
- # not used yet ...
- # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id
- if db_server == 'mysql':
- self.query['get_date_nhands_ago'] = """
- select concat( 'd', date_format(max(h.handStart), '%Y%m%d') )
- from (select hp.playerId
- ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
- from HandsPlayers hp
- where hp.playerId = %s
- group by hp.playerId) hp2
- inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
- and hp3.playerId = hp2.playerId)
- inner join Hands h on (h.id = hp3.handId)
- """
- elif db_server == 'postgresql':
- self.query['get_date_nhands_ago'] = """
- select 'd' || to_char(max(h3.handStart), 'YYMMDD')
- from (select hp.playerId
- ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
- from HandsPlayers hp
- where hp.playerId = %s
- group by hp.playerId) hp2
- inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
- and hp3.playerId = hp2.playerId)
- inner join Hands h on (h.id = hp3.handId)
- """
- elif db_server == 'sqlite': # untested guess at query:
- self.query['get_date_nhands_ago'] = """
- select 'd' || strftime(max(h3.handStart), 'YYMMDD')
- from (select hp.playerId
- ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
- from HandsPlayers hp
- where hp.playerId = %s
- group by hp.playerId) hp2
- inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
- and hp3.playerId = hp2.playerId)
- inner join Hands h on (h.id = hp3.handId)
- """
+ self.query['get_actual_seat'] = """
+ select seatNo
+ from HandsPlayers
+ where HandsPlayers.handId = %s
+ and HandsPlayers.playerId = (select Players.id from Players
+ where Players.name = %s)
+ """
- # used in GuiPlayerStats:
- self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
+ self.query['get_cards'] = """
+ select
+ seatNo AS seat_number,
+ card1, /*card1Value, card1Suit, */
+ card2, /*card2Value, card2Suit, */
+ card3, /*card3Value, card3Suit, */
+ card4, /*card4Value, card4Suit, */
+ card5, /*card5Value, card5Suit, */
+ card6, /*card6Value, card6Suit, */
+ card7 /*card7Value, card7Suit */
+ from HandsPlayers, Players
+ where handID = %s and HandsPlayers.playerId = Players.id
+ order by seatNo
+ """
- self.query['getPlayerIdBySite'] = """SELECT id from Players where name = %s AND siteId = %s"""
+ self.query['get_common_cards'] = """
+ select
+ boardcard1,
+ boardcard2,
+ boardcard3,
+ boardcard4,
+ boardcard5
+ from Hands
+ where Id = %s
+ """
+
+ self.query['get_action_from_hand'] = """
+ SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
+ FROM Players, HandsActions, HandsPlayers
+ WHERE HandsPlayers.handid = %s
+ AND HandsPlayers.playerid = Players.id
+ AND HandsActions.handsPlayerId = HandsPlayers.id
+ ORDER BY street, actionno
+ """
+
+ if db_server == 'mysql':
+ self.query['get_hand_1day_ago'] = """
+ select coalesce(max(id),0)
+ from Hands
+ where handStart < date_sub(utc_timestamp(), interval '1' day)"""
+ elif db_server == 'postgresql':
+ self.query['get_hand_1day_ago'] = """
+ select coalesce(max(id),0)
+ from Hands
+ where handStart < now() at time zone 'UTC' - interval '1 day'"""
+ elif db_server == 'sqlite':
+ self.query['get_hand_1day_ago'] = """
+ select coalesce(max(id),0)
+ from Hands
+ where handStart < strftime('%J', 'now') - 1"""
+
+ # not used yet ...
+ # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id
+ if db_server == 'mysql':
+ self.query['get_date_nhands_ago'] = """
+ select concat( 'd', date_format(max(h.handStart), '%Y%m%d') )
+ from (select hp.playerId
+ ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
+ from HandsPlayers hp
+ where hp.playerId = %s
+ group by hp.playerId) hp2
+ inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
+ and hp3.playerId = hp2.playerId)
+ inner join Hands h on (h.id = hp3.handId)
+ """
+ elif db_server == 'postgresql':
+ self.query['get_date_nhands_ago'] = """
+ select 'd' || to_char(max(h3.handStart), 'YYMMDD')
+ from (select hp.playerId
+ ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
+ from HandsPlayers hp
+ where hp.playerId = %s
+ group by hp.playerId) hp2
+ inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
+ and hp3.playerId = hp2.playerId)
+ inner join Hands h on (h.id = hp3.handId)
+ """
+ elif db_server == 'sqlite': # untested guess at query:
+ self.query['get_date_nhands_ago'] = """
+ select 'd' || strftime(max(h3.handStart), 'YYMMDD')
+ from (select hp.playerId
+ ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
+ from HandsPlayers hp
+ where hp.playerId = %s
+ group by hp.playerId) hp2
+ inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
+ and hp3.playerId = hp2.playerId)
+ inner join Hands h on (h.id = hp3.handId)
+ """
+
+ # used in GuiPlayerStats:
+ self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
+
+ self.query['getPlayerIdBySite'] = """SELECT id from Players where name = %s AND siteId = %s"""
- # used in Filters:
- self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
- self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
- self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC"""
- self.query['getLimits2'] = """SELECT DISTINCT type, limitType, bigBlind
- from Gametypes
- ORDER by type, limitType DESC, bigBlind DESC"""
+ # used in Filters:
+ self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
+ self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
+ self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC"""
+ self.query['getLimits2'] = """SELECT DISTINCT type, limitType, bigBlind
+ from Gametypes
+ ORDER by type, limitType DESC, bigBlind DESC"""
- if db_server == 'mysql':
- self.query['playerDetailedStats'] = """
- select AS hgametypeid
- , AS pname
- ,gt.base
- ,gt.category
- ,upper(gt.limitType) AS limittype
- ,s.name
- ,min(gt.bigBlind) AS minbigblind
- ,max(gt.bigBlind) AS maxbigblind
- /*, AS gtid*/
- , AS plposition
- ,count(1) AS n
- ,100.0*sum(cast(hp.street0VPI as integer))/count(1) AS vpip
- ,100.0*sum(cast(hp.street0Aggr as integer))/count(1) AS pfr
- ,case when sum(cast(hp.street0_3Bchance as integer)) = 0 then -999
- else 100.0*sum(cast(hp.street0_3Bdone as integer))/sum(cast(hp.street0_3Bchance as integer))
- end AS pf3
- ,case when sum(cast(hp.stealattemptchance as integer)) = 0 then -999
- else 100.0*sum(cast(hp.stealattempted as integer))/sum(cast(hp.stealattemptchance as integer))
- end AS steals
- ,100.0*sum(cast(hp.street1Seen as integer))/count(1) AS saw_f
- ,100.0*sum(cast(hp.sawShowdown as integer))/count(1) AS sawsd
- ,case when sum(cast(hp.street1Seen as integer)) = 0 then -999
- else 100.0*sum(cast(hp.sawShowdown as integer))/sum(cast(hp.street1Seen as integer))
- end AS wtsdwsf
- ,case when sum(cast(hp.sawShowdown as integer)) = 0 then -999
- else 100.0*sum(cast(hp.wonAtSD as integer))/sum(cast(hp.sawShowdown as integer))
- end AS wmsd
- ,case when sum(cast(hp.street1Seen as integer)) = 0 then -999
- else 100.0*sum(cast(hp.street1Aggr as integer))/sum(cast(hp.street1Seen as integer))
- end AS flafq
- ,case when sum(cast(hp.street2Seen as integer)) = 0 then -999
- else 100.0*sum(cast(hp.street2Aggr as integer))/sum(cast(hp.street2Seen as integer))
- end AS tuafq
- ,case when sum(cast(hp.street3Seen as integer)) = 0 then -999
- else 100.0*sum(cast(hp.street3Aggr as integer))/sum(cast(hp.street3Seen as integer))
- end AS rvafq
- ,case when sum(cast(hp.street1Seen as integer))+sum(cast(hp.street2Seen as integer))+sum(cast(hp.street3Seen as integer)) = 0 then -999
- else 100.0*(sum(cast(hp.street1Aggr as integer))+sum(cast(hp.street2Aggr as integer))+sum(cast(hp.street3Aggr as