Coverage for SQL.py: 76%
547 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-28 16:41 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3"""Returns a dict of SQL statements used in fpdb.
4"""
5from __future__ import print_function
6# Copyright 2008-2011, Ray E. Barker
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22# NOTES: The sql statements use the placeholder %s for bind variables
23# which is then replaced by ? for sqlite. Comments can be included
24# within sql statements using C style /* ... */ comments, BUT
25# THE COMMENTS MUST NOT INCLUDE %s OR ?.
27########################################################################
29# Standard Library modules
31import re
33# pyGTK modules
35# FreePokerTools modules
37class Sql(object):
39 def __init__(self, game='holdem', db_server='mysql'):
40 self.query = {}
41###############################################################################3
42# Support for the Free Poker DataBase = fpdb http://fpdb.sourceforge.net/
43#
45 ################################
46 # List tables
47 ################################
48 if db_server == 'mysql':
49 self.query['list_tables'] = """SHOW TABLES"""
50 elif db_server == 'postgresql':
51 self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"""
52 elif db_server == 'sqlite':
53 self.query['list_tables'] = """SELECT name FROM sqlite_master
54 WHERE type='table'
55 ORDER BY name;"""
57 ################################
58 # List indexes
59 ################################
60 if db_server == 'mysql':
61 self.query['list_indexes'] = """SHOW INDEXES"""
62 elif db_server == 'postgresql':
63 self.query['list_indexes'] = """SELECT tablename, indexname FROM PG_INDEXES"""
64 elif db_server == 'sqlite':
65 self.query['list_indexes'] = """SELECT name FROM sqlite_master
66 WHERE type='index'
67 ORDER BY name;"""
69 ##################################################################
70 # Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax
71 ##################################################################
73 self.query['drop_table'] = """DROP TABLE IF EXISTS """
76 ##################################################################
77 # Set transaction isolation level
78 ##################################################################
80 if db_server == 'mysql' or db_server == 'postgresql':
81 self.query['set tx level'] = """SET SESSION TRANSACTION
82 ISOLATION LEVEL READ COMMITTED"""
83 elif db_server == 'sqlite':
84 self.query['set tx level'] = """ """
87 ################################
88 # Select basic info
89 ################################
91 self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
93 self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
95 self.query['getCurrencies'] = """SELECT DISTINCT currency from Gametypes ORDER BY currency"""
97 self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC"""
99 self.query['getTourneyTypesIds'] = "SELECT id FROM TourneyTypes"
101 self.query['getTourneyTypes'] = "SELECT DISTINCT tourneyName FROM Tourneys"
103 self.query['getTourneyNames'] = "SELECT tourneyName FROM Tourneys"
105 ################################
106 # Create Settings
107 ################################
108 if db_server == 'mysql':
109 self.query['createSettingsTable'] = """CREATE TABLE Settings (
110 version SMALLINT NOT NULL)
111 ENGINE=INNODB"""
112 elif db_server == 'postgresql':
113 self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT NOT NULL)"""
115 elif db_server == 'sqlite':
116 self.query['createSettingsTable'] = """CREATE TABLE Settings
117 (version INTEGER NOT NULL) """
119 ################################
120 # Create InsertLock
121 ################################
122 if db_server == 'mysql':
123 self.query['createLockTable'] = """CREATE TABLE InsertLock (
124 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
125 locked BOOLEAN NOT NULL DEFAULT FALSE)
126 ENGINE=INNODB"""
128 ################################
129 # Create RawHands (this table is all but identical with RawTourneys)
130 ################################
131 if db_server == 'mysql':
132 self.query['createRawHands'] = """CREATE TABLE RawHands (
133 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
134 handId BIGINT NOT NULL,
135 rawHand TEXT NOT NULL,
136 complain BOOLEAN NOT NULL DEFAULT FALSE)
137 ENGINE=INNODB"""
138 elif db_server == 'postgresql':
139 self.query['createRawHands'] = """CREATE TABLE RawHands (
140 id BIGSERIAL, PRIMARY KEY (id),
141 handId BIGINT NOT NULL,
142 rawHand TEXT NOT NULL,
143 complain BOOLEAN NOT NULL DEFAULT FALSE)"""
144 elif db_server == 'sqlite':
145 self.query['createRawHands'] = """CREATE TABLE RawHands (
146 id INTEGER PRIMARY KEY,
147 handId BIGINT NOT NULL,
148 rawHand TEXT NOT NULL,
149 complain BOOLEAN NOT NULL DEFAULT FALSE)"""
151 ################################
152 # Create RawTourneys (this table is all but identical with RawHands)
153 ################################
154 if db_server == 'mysql':
155 self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
156 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
157 tourneyId BIGINT NOT NULL,
158 rawTourney TEXT NOT NULL,
159 complain BOOLEAN NOT NULL DEFAULT FALSE)
160 ENGINE=INNODB"""
161 elif db_server == 'postgresql':
162 self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
163 id BIGSERIAL, PRIMARY KEY (id),
164 tourneyId BIGINT NOT NULL,
165 rawTourney TEXT NOT NULL,
166 complain BOOLEAN NOT NULL DEFAULT FALSE)"""
167 elif db_server == 'sqlite':
168 self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
169 id INTEGER PRIMARY KEY,
170 tourneyId BIGINT NOT NULL,
171 rawTourney TEXT NOT NULL,
172 complain BOOLEAN NOT NULL DEFAULT FALSE)"""
174 ################################
175 # Create Actions
176 ################################
178 if db_server == 'mysql':
179 self.query['createActionsTable'] = """CREATE TABLE Actions (
180 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
181 name varchar(32) NOT NULL,
182 code char(4) NOT NULL)
183 ENGINE=INNODB"""
184 elif db_server == 'postgresql':
185 self.query['createActionsTable'] = """CREATE TABLE Actions (
186 id SERIAL, PRIMARY KEY (id),
187 name varchar(32),
188 code char(4))"""
189 elif db_server == 'sqlite':
190 self.query['createActionsTable'] = """CREATE TABLE Actions (
191 id INTEGER PRIMARY KEY,
192 name TEXT NOT NULL,
193 code TEXT NOT NULL)"""
195 ################################
196 # Create Rank
197 ################################
199 if db_server == 'mysql':
200 self.query['createRankTable'] = """CREATE TABLE Rank (
201 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
202 name varchar(8) NOT NULL)
203 ENGINE=INNODB"""
205 elif db_server == 'postgresql':
206 self.query['createRankTable'] = """CREATE TABLE Rank (
207 id SERIAL, PRIMARY KEY (id),
208 name varchar(8))"""
209 elif db_server == 'sqlite':
210 self.query['createRankTable'] = """CREATE TABLE Rank (
211 id INTEGER PRIMARY KEY,
212 name TEXT NOT NULL)"""
214 ################################
215 # Create StartCards
216 ################################
218 if db_server == 'mysql':
219 self.query['createStartCardsTable'] = """CREATE TABLE StartCards (
220 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
221 category varchar(9) NOT NULL,
222 name varchar(32) NOT NULL,
223 rank SMALLINT NOT NULL,
224 combinations SMALLINT NOT NULL)
225 ENGINE=INNODB"""
227 elif db_server == 'postgresql':
228 self.query['createStartCardsTable'] = """CREATE TABLE StartCards (
229 id SERIAL, PRIMARY KEY (id),
230 category varchar(9) NOT NULL,
231 name varchar(32),
232 rank SMALLINT NOT NULL,
233 combinations SMALLINT NOT NULL)"""
235 elif db_server == 'sqlite':
236 self.query['createStartCardsTable'] = """CREATE TABLE StartCards (
237 id INTEGER PRIMARY KEY,
238 category TEXT NOT NULL,
239 name TEXT NOT NULL,
240 rank SMALLINT NOT NULL,
241 combinations SMALLINT NOT NULL)"""
243 ################################
244 # Create Sites
245 ################################
247 if db_server == 'mysql':
248 self.query['createSitesTable'] = """CREATE TABLE Sites (
249 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
250 name varchar(32) NOT NULL,
251 code char(2) NOT NULL)
252 ENGINE=INNODB"""
253 elif db_server == 'postgresql':
254 self.query['createSitesTable'] = """CREATE TABLE Sites (
255 id SERIAL, PRIMARY KEY (id),
256 name varchar(32),
257 code char(2))"""
258 elif db_server == 'sqlite':
259 self.query['createSitesTable'] = """CREATE TABLE Sites (
260 id INTEGER PRIMARY KEY,
261 name TEXT NOT NULL,
262 code TEXT NOT NULL)"""
264 ################################
265 # Create Backings
266 ################################
268 if db_server == 'mysql':
269 self.query['createBackingsTable'] = """CREATE TABLE Backings (
270 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
271 tourneysPlayersId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id),
272 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
273 buyInPercentage FLOAT UNSIGNED NOT NULL,
274 payOffPercentage FLOAT UNSIGNED NOT NULL) ENGINE=INNODB"""
275 elif db_server == 'postgresql':
276 self.query['createBackingsTable'] = """CREATE TABLE Backings (
277 id BIGSERIAL, PRIMARY KEY (id),
278 tourneysPlayersId INT NOT NULL, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id),
279 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
280 buyInPercentage FLOAT NOT NULL,
281 payOffPercentage FLOAT NOT NULL)"""
282 elif db_server == 'sqlite':
283 self.query['createBackingsTable'] = """CREATE TABLE Backings (
284 id INTEGER PRIMARY KEY,
285 tourneysPlayersId INT NOT NULL,
286 playerId INT NOT NULL,
287 buyInPercentage REAL UNSIGNED NOT NULL,
288 payOffPercentage REAL UNSIGNED NOT NULL)"""
290 ################################
291 # Create Gametypes
292 ################################
294 if db_server == 'mysql':
295 self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
296 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
297 siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
298 currency varchar(4) NOT NULL,
299 type char(4) NOT NULL,
300 base char(4) NOT NULL,
301 category varchar(9) NOT NULL,
302 limitType char(2) NOT NULL,
303 hiLo char(1) NOT NULL,
304 mix varchar(9) NOT NULL,
305 smallBlind bigint,
306 bigBlind bigint,
307 smallBet bigint NOT NULL,
308 bigBet bigint NOT NULL,
309 maxSeats TINYINT NOT NULL,
310 ante INT NOT NULL,
311 buyinType varchar(9) NOT NULL,
312 fast BOOLEAN,
313 newToGame BOOLEAN,
314 homeGame BOOLEAN,
315 split BOOLEAN)
316 ENGINE=INNODB"""
317 elif db_server == 'postgresql':
318 self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
319 id SERIAL NOT NULL, PRIMARY KEY (id),
320 siteId INTEGER NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
321 currency varchar(4) NOT NULL,
322 type char(4) NOT NULL,
323 base char(4) NOT NULL,
324 category varchar(9) NOT NULL,
325 limitType char(2) NOT NULL,
326 hiLo char(1) NOT NULL,
327 mix varchar(9) NOT NULL,
328 smallBlind bigint,
329 bigBlind bigint,
330 smallBet bigint NOT NULL,
331 bigBet bigint NOT NULL,
332 maxSeats SMALLINT NOT NULL,
333 ante INT NOT NULL,
334 buyinType varchar(9) NOT NULL,
335 fast BOOLEAN,
336 newToGame BOOLEAN,
337 homeGame BOOLEAN,
338 split BOOLEAN)"""
339 elif db_server == 'sqlite':
340 self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
341 id INTEGER PRIMARY KEY NOT NULL,
342 siteId INTEGER NOT NULL,
343 currency TEXT NOT NULL,
344 type TEXT NOT NULL,
345 base TEXT NOT NULL,
346 category TEXT NOT NULL,
347 limitType TEXT NOT NULL,
348 hiLo TEXT NOT NULL,
349 mix TEXT NOT NULL,
350 smallBlind INTEGER,
351 bigBlind INTEGER,
352 smallBet INTEGER NOT NULL,
353 bigBet INTEGER NOT NULL,
354 maxSeats INT NOT NULL,
355 ante INT NOT NULL,
356 buyinType TEXT NOT NULL,
357 fast INT,
358 newToGame INT,
359 homeGame INT,
360 split INT,
361 FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
364 ################################
365 # Create Players
366 ################################
368 if db_server == 'mysql':
369 self.query['createPlayersTable'] = """CREATE TABLE Players (
370 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
371 name VARCHAR(32) NOT NULL,
372 siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
373 hero BOOLEAN,
374 chars char(3),
375 comment text,
376 commentTs DATETIME,
377 profil text,
378 color_code VARCHAR(7) DEFAULT '#FFFFFF',
379 symbol VARCHAR(10) DEFAULT '★'
380 )
381 ENGINE=INNODB"""
382 elif db_server == 'postgresql':
383 self.query['createPlayersTable'] = """CREATE TABLE Players (
384 id SERIAL, PRIMARY KEY (id),
385 name VARCHAR(32),
386 siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
387 hero BOOLEAN,
388 chars char(3),
389 comment text,
390 commentTs timestamp without time zone,
391 profil text,
392 color_code VARCHAR(7) DEFAULT '#FFFFFF',
393 symbol VARCHAR(10) DEFAULT '★' )"""
394 elif db_server == 'sqlite':
395 self.query['createPlayersTable'] = """CREATE TABLE Players (
396 id INTEGER PRIMARY KEY,
397 name TEXT,
398 siteId INTEGER,
399 hero BOOLEAN,
400 chars TEXT,
401 comment TEXT,
402 commentTs timestamp,
403 profil TEXT,
404 color_code TEXT DEFAULT '#FFFFFF',
405 symbol TEXT DEFAULT '★',
406 FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)"""
409 ################################
410 # Create Autorates
411 ################################
413 if db_server == 'mysql':
414 self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
415 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
416 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
417 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
418 description varchar(50) NOT NULL,
419 shortDesc char(8) NOT NULL,
420 ratingTime DATETIME NOT NULL,
421 handCount int NOT NULL)
422 ENGINE=INNODB"""
423 elif db_server == 'postgresql':
424 self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
425 id BIGSERIAL, PRIMARY KEY (id),
426 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
427 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
428 description varchar(50),
429 shortDesc char(8),
430 ratingTime timestamp without time zone,
431 handCount int)"""
432 elif db_server == 'sqlite':
433 self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
434 id INTEGER PRIMARY KEY,
435 playerId INT,
436 gametypeId INT,
437 description TEXT,
438 shortDesc TEXT,
439 ratingTime timestamp,
440 handCount int)"""
443 ################################
444 # Create Hands
445 ################################
447 if db_server == 'mysql':
448 self.query['createHandsTable'] = """CREATE TABLE Hands (
449 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
450 tableName VARCHAR(50) NOT NULL,
451 siteHandNo BIGINT NOT NULL,
452 tourneyId INT UNSIGNED, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
453 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
454 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
455 fileId INT(10) UNSIGNED NOT NULL, FOREIGN KEY (fileId) REFERENCES Files(id),
456 startTime DATETIME NOT NULL,
457 importTime DATETIME NOT NULL,
458 seats TINYINT NOT NULL,
459 heroSeat TINYINT NOT NULL,
460 maxPosition TINYINT NOT NULL,
461 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
462 boardcard2 smallint,
463 boardcard3 smallint,
464 boardcard4 smallint,
465 boardcard5 smallint,
466 texture smallint,
467 runItTwice BOOLEAN,
468 playersVpi SMALLINT NOT NULL, /* num of players vpi */
469 playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
470 playersAtStreet2 SMALLINT NOT NULL,
471 playersAtStreet3 SMALLINT NOT NULL,
472 playersAtStreet4 SMALLINT NOT NULL,
473 playersAtShowdown SMALLINT NOT NULL,
474 street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
475 street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */
476 street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */
477 street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */
478 street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
479 street0Pot BIGINT, /* pot size at pre-flop/street2 */
480 street1Pot BIGINT, /* pot size at flop/street4 */
481 street2Pot BIGINT, /* pot size at turn/street5 */
482 street3Pot BIGINT, /* pot size at river/street6 */
483 street4Pot BIGINT, /* pot size at sd/street7 */
484 finalPot BIGINT, /* final pot size */
485 comment TEXT,
486 commentTs DATETIME)
487 ENGINE=INNODB"""
488 elif db_server == 'postgresql':
489 self.query['createHandsTable'] = """CREATE TABLE Hands (
490 id BIGSERIAL, PRIMARY KEY (id),
491 tableName VARCHAR(50) NOT NULL,
492 siteHandNo BIGINT NOT NULL,
493 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
494 gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
495 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
496 fileId BIGINT NOT NULL, FOREIGN KEY (fileId) REFERENCES Files(id),
497 startTime timestamp without time zone NOT NULL,
498 importTime timestamp without time zone NOT NULL,
499 seats SMALLINT NOT NULL,
500 heroSeat SMALLINT NOT NULL,
501 maxPosition SMALLINT NOT NULL,
502 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
503 boardcard2 smallint,
504 boardcard3 smallint,
505 boardcard4 smallint,
506 boardcard5 smallint,
507 texture smallint,
508 runItTwice BOOLEAN,
509 playersVpi SMALLINT NOT NULL, /* num of players vpi */
510 playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
511 playersAtStreet2 SMALLINT NOT NULL,
512 playersAtStreet3 SMALLINT NOT NULL,
513 playersAtStreet4 SMALLINT NOT NULL,
514 playersAtShowdown SMALLINT NOT NULL,
515 street0Raises SMALLINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
516 street1Raises SMALLINT NOT NULL, /* num small bets paid to see turn/street5 */
517 street2Raises SMALLINT NOT NULL, /* num big bets paid to see river/street6 */
518 street3Raises SMALLINT NOT NULL, /* num big bets paid to see sd/street7 */
519 street4Raises SMALLINT NOT NULL, /* num big bets paid to see showdown */
520 street0Pot BIGINT, /* pot size at preflop/street3 */
521 street1Pot BIGINT, /* pot size at flop/street4 */
522 street2Pot BIGINT, /* pot size at turn/street5 */
523 street3Pot BIGINT, /* pot size at river/street6 */
524 street4Pot BIGINT, /* pot size at sd/street7 */
525 finalPot BIGINT, /* final pot size */
526 comment TEXT,
527 commentTs timestamp without time zone)"""
528 elif db_server == 'sqlite':
529 self.query['createHandsTable'] = """CREATE TABLE Hands (
530 id INTEGER PRIMARY KEY,
531 tableName TEXT(50) NOT NULL,
532 siteHandNo INT NOT NULL,
533 tourneyId INT,
534 gametypeId INT NOT NULL,
535 sessionId INT,
536 fileId INT NOT NULL,
537 startTime timestamp NOT NULL,
538 importTime timestamp NOT NULL,
539 seats INT NOT NULL,
540 heroSeat INT NOT NULL,
541 maxPosition INT NOT NULL,
542 boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
543 boardcard2 INT,
544 boardcard3 INT,
545 boardcard4 INT,
546 boardcard5 INT,
547 texture INT,
548 runItTwice BOOLEAN,
549 playersVpi INT NOT NULL, /* num of players vpi */
550 playersAtStreet1 INT NOT NULL, /* num of players seeing flop/street4 */
551 playersAtStreet2 INT NOT NULL,
552 playersAtStreet3 INT NOT NULL,
553 playersAtStreet4 INT NOT NULL,
554 playersAtShowdown INT NOT NULL,
555 street0Raises INT NOT NULL, /* num small bets paid to see flop/street4, including blind */
556 street1Raises INT NOT NULL, /* num small bets paid to see turn/street5 */
557 street2Raises INT NOT NULL, /* num big bets paid to see river/street6 */
558 street3Raises INT NOT NULL, /* num big bets paid to see sd/street7 */
559 street4Raises INT NOT NULL, /* num big bets paid to see showdown */
560 street0Pot INT, /* pot size at preflop/street3 */
561 street1Pot INT, /* pot size at flop/street4 */
562 street2Pot INT, /* pot size at turn/street5 */
563 street3Pot INT, /* pot size at river/street6 */
564 street4Pot INT, /* pot size at sd/street7 */
565 finalPot INT, /* final pot size */
566 comment TEXT,
567 commentTs timestamp)"""
569 ################################
570 # Create Boards
571 ################################
573 if db_server == 'mysql':
574 self.query['createBoardsTable'] = """CREATE TABLE Boards (
575 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
576 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
577 boardId smallint,
578 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
579 boardcard2 smallint,
580 boardcard3 smallint,
581 boardcard4 smallint,
582 boardcard5 smallint)
583 ENGINE=INNODB"""
584 elif db_server == 'postgresql':
585 self.query['createBoardsTable'] = """CREATE TABLE Boards (
586 id BIGSERIAL, PRIMARY KEY (id),
587 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
588 boardId smallint,
589 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
590 boardcard2 smallint,
591 boardcard3 smallint,
592 boardcard4 smallint,
593 boardcard5 smallint)"""
594 elif db_server == 'sqlite':
595 self.query['createBoardsTable'] = """CREATE TABLE Boards (
596 id INTEGER PRIMARY KEY,
597 handId INT NOT NULL,
598 boardId INT,
599 boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
600 boardcard2 INT,
601 boardcard3 INT,
602 boardcard4 INT,
603 boardcard5 INT)"""
615 ################################
616 # Create TourneyTypes
617 ################################
619 if db_server == 'mysql':
620 self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
621 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
622 siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
623 currency varchar(4),
624 buyIn BIGINT,
625 fee BIGINT,
626 category varchar(9) NOT NULL,
627 limitType char(2) NOT NULL,
628 buyInChips BIGINT,
629 stack varchar(8),
630 maxSeats INT,
631 rebuy BOOLEAN,
632 rebuyCost BIGINT,
633 rebuyFee BIGINT,
634 rebuyChips BIGINT,
635 addOn BOOLEAN,
636 addOnCost BIGINT,
637 addOnFee BIGINT,
638 addOnChips BIGINT,
639 knockout BOOLEAN,
640 koBounty BIGINT,
641 progressive BOOLEAN,
642 step BOOLEAN,
643 stepNo INT,
644 chance BOOLEAN,
645 chanceCount INT,
646 speed varchar(10),
647 shootout BOOLEAN,
648 matrix BOOLEAN,
649 multiEntry BOOLEAN,
650 reEntry BOOLEAN,
651 fast BOOLEAN,
652 newToGame BOOLEAN,
653 homeGame BOOLEAN,
654 split BOOLEAN,
655 sng BOOLEAN,
656 fifty50 BOOLEAN,
657 time BOOLEAN,
658 timeAmt INT,
659 satellite BOOLEAN,
660 doubleOrNothing BOOLEAN,
661 cashOut BOOLEAN,
662 onDemand BOOLEAN,
663 flighted BOOLEAN,
664 guarantee BOOLEAN,
665 guaranteeAmt BIGINT)
666 ENGINE=INNODB"""
667 elif db_server == 'postgresql':
668 self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
669 id SERIAL, PRIMARY KEY (id),
670 siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
671 currency varchar(4),
672 buyin BIGINT,
673 fee BIGINT,
674 category varchar(9),
675 limitType char(2),
676 buyInChips BIGINT,
677 stack varchar(8),
678 maxSeats INT,
679 rebuy BOOLEAN,
680 rebuyCost BIGINT,
681 rebuyFee BIGINT,
682 rebuyChips BIGINT,
683 addOn BOOLEAN,
684 addOnCost BIGINT,
685 addOnFee BIGINT,
686 addOnChips BIGINT,
687 knockout BOOLEAN,
688 koBounty BIGINT,
689 progressive BOOLEAN,
690 step BOOLEAN,
691 stepNo INT,
692 chance BOOLEAN,
693 chanceCount INT,
694 speed varchar(10),
695 shootout BOOLEAN,
696 matrix BOOLEAN,
697 multiEntry BOOLEAN,
698 reEntry BOOLEAN,
699 fast BOOLEAN,
700 newToGame BOOLEAN,
701 homeGame BOOLEAN,
702 split BOOLEAN,
703 sng BOOLEAN,
704 fifty50 BOOLEAN,
705 time BOOLEAN,
706 timeAmt INT,
707 satellite BOOLEAN,
708 doubleOrNothing BOOLEAN,
709 cashOut BOOLEAN,
710 onDemand BOOLEAN,
711 flighted BOOLEAN,
712 guarantee BOOLEAN,
713 guaranteeAmt BIGINT)"""
714 elif db_server == 'sqlite':
715 self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
716 id INTEGER PRIMARY KEY,
717 siteId INT NOT NULL,
718 currency VARCHAR(4),
719 buyin INT,
720 fee INT,
721 category TEXT,
722 limitType TEXT,
723 buyInChips INT,
724 stack VARCHAR(8),
725 maxSeats INT,
726 rebuy BOOLEAN,
727 rebuyCost INT,
728 rebuyFee INT,
729 rebuyChips INT,
730 addOn BOOLEAN,
731 addOnCost INT,
732 addOnFee INT,
733 addOnChips INT,
734 knockout BOOLEAN,
735 koBounty INT,
736 progressive BOOLEAN,
737 step BOOLEAN,
738 stepNo INT,
739 chance BOOLEAN,
740 chanceCount INT,
741 speed TEXT,
742 shootout BOOLEAN,
743 matrix BOOLEAN,
744 multiEntry BOOLEAN,
745 reEntry BOOLEAN,
746 fast BOOLEAN,
747 newToGame BOOLEAN,
748 homeGame BOOLEAN,
749 split BOOLEAN,
750 sng BOOLEAN,
751 fifty50 BOOLEAN,
752 time BOOLEAN,
753 timeAmt INT,
754 satellite BOOLEAN,
755 doubleOrNothing BOOLEAN,
756 cashOut BOOLEAN,
757 onDemand BOOLEAN,
758 flighted BOOLEAN,
759 guarantee BOOLEAN,
760 guaranteeAmt INT)"""
762 ################################
763 # Create Tourneys
764 ################################
766 if db_server == 'mysql':
767 self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
768 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
769 tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
770 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
771 siteTourneyNo BIGINT NOT NULL,
772 entries INT,
773 prizepool BIGINT,
774 startTime DATETIME,
775 endTime DATETIME,
776 tourneyName TEXT,
777 totalRebuyCount INT,
778 totalAddOnCount INT,
779 added BIGINT,
780 addedCurrency VARCHAR(4),
781 comment TEXT,
782 commentTs DATETIME)
783 ENGINE=INNODB"""
784 elif db_server == 'postgresql':
785 self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
786 id SERIAL, PRIMARY KEY (id),
787 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
788 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
789 siteTourneyNo BIGINT,
790 entries INT,
791 prizepool BIGINT,
792 startTime timestamp without time zone,
793 endTime timestamp without time zone,
794 tourneyName TEXT,
795 totalRebuyCount INT,
796 totalAddOnCount INT,
797 added BIGINT,
798 addedCurrency VARCHAR(4),
799 comment TEXT,
800 commentTs timestamp without time zone)"""
801 elif db_server == 'sqlite':
802 self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
803 id INTEGER PRIMARY KEY,
804 tourneyTypeId INT,
805 sessionId INT,
806 siteTourneyNo INT,
807 entries INT,
808 prizepool INT,
809 startTime timestamp,
810 endTime timestamp,
811 tourneyName TEXT,
812 totalRebuyCount INT,
813 totalAddOnCount INT,
814 added INT,
815 addedCurrency VARCHAR(4),
816 comment TEXT,
817 commentTs timestamp)"""
819 ################################
820 # Create HandsPlayers
821 ################################
823 if db_server == 'mysql':
824 self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
825 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
826 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
827 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
828 startCash BIGINT NOT NULL,
829 effStack BIGINT NOT NULL,
830 startBounty BIGINT,
831 endBounty BIGINT,
832 position CHAR(1),
833 seatNo SMALLINT NOT NULL,
834 sitout BOOLEAN NOT NULL,
836 card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
837 card2 smallint NOT NULL,
838 card3 smallint,
839 card4 smallint,
840 card5 smallint,
841 card6 smallint,
842 card7 smallint,
843 card8 smallint, /* cards 8-20 for draw hands */
844 card9 smallint,
845 card10 smallint,
846 card11 smallint,
847 card12 smallint,
848 card13 smallint,
849 card14 smallint,
850 card15 smallint,
851 card16 smallint,
852 card17 smallint,
853 card18 smallint,
854 card19 smallint,
855 card20 smallint,
856 startCards SMALLINT UNSIGNED, FOREIGN KEY (startCards) REFERENCES StartCards(id),
858 common BIGINT NOT NULL,
859 committed BIGINT NOT NULL,
860 winnings BIGINT NOT NULL,
861 rake BIGINT NOT NULL,
862 rakeDealt NUMERIC NOT NULL,
863 rakeContributed NUMERIC NOT NULL,
864 rakeWeighted NUMERIC NOT NULL,
865 totalProfit BIGINT,
866 allInEV NUMERIC,
867 comment text,
868 commentTs DATETIME,
869 tourneysPlayersId BIGINT UNSIGNED, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id),
871 wonWhenSeenStreet1 BOOLEAN,
872 wonWhenSeenStreet2 BOOLEAN,
873 wonWhenSeenStreet3 BOOLEAN,
874 wonWhenSeenStreet4 BOOLEAN,
875 wonAtSD BOOLEAN,
877 street0VPIChance BOOLEAN,
878 street0VPI BOOLEAN,
879 street0AggrChance BOOLEAN,
880 street0Aggr BOOLEAN,
881 street0CalledRaiseChance TINYINT,
882 street0CalledRaiseDone TINYINT,
883 street0_2BChance BOOLEAN,
884 street0_2BDone BOOLEAN,
885 street0_3BChance BOOLEAN,
886 street0_3BDone BOOLEAN,
887 street0_4BChance BOOLEAN,
888 street0_C4BChance BOOLEAN,
889 street0_4BDone BOOLEAN,
890 street0_C4BDone BOOLEAN,
891 street0_FoldTo2BChance BOOLEAN,
892 street0_FoldTo2BDone BOOLEAN,
893 street0_FoldTo3BChance BOOLEAN,
894 street0_FoldTo3BDone BOOLEAN,
895 street0_FoldTo4BChance BOOLEAN,
896 street0_FoldTo4BDone BOOLEAN,
897 street0_SqueezeChance BOOLEAN,
898 street0_SqueezeDone BOOLEAN,
900 raiseToStealChance BOOLEAN,
901 raiseToStealDone BOOLEAN,
902 stealChance BOOLEAN,
903 stealDone BOOLEAN,
904 success_Steal BOOLEAN,
906 street1Seen BOOLEAN,
907 street2Seen BOOLEAN,
908 street3Seen BOOLEAN,
909 street4Seen BOOLEAN,
910 sawShowdown BOOLEAN,
911 showed BOOLEAN,
913 street0AllIn BOOLEAN,
914 street1AllIn BOOLEAN,
915 street2AllIn BOOLEAN,
916 street3AllIn BOOLEAN,
917 street4AllIn BOOLEAN,
918 wentAllIn BOOLEAN,
920 street0InPosition BOOLEAN,
921 street1InPosition BOOLEAN,
922 street2InPosition BOOLEAN,
923 street3InPosition BOOLEAN,
924 street4InPosition BOOLEAN,
925 street0FirstToAct BOOLEAN,
926 street1FirstToAct BOOLEAN,
927 street2FirstToAct BOOLEAN,
928 street3FirstToAct BOOLEAN,
929 street4FirstToAct BOOLEAN,
931 street1Aggr BOOLEAN,
932 street2Aggr BOOLEAN,
933 street3Aggr BOOLEAN,
934 street4Aggr BOOLEAN,
936 otherRaisedStreet0 BOOLEAN,
937 otherRaisedStreet1 BOOLEAN,
938 otherRaisedStreet2 BOOLEAN,
939 otherRaisedStreet3 BOOLEAN,
940 otherRaisedStreet4 BOOLEAN,
941 foldToOtherRaisedStreet0 BOOLEAN,
942 foldToOtherRaisedStreet1 BOOLEAN,
943 foldToOtherRaisedStreet2 BOOLEAN,
944 foldToOtherRaisedStreet3 BOOLEAN,
945 foldToOtherRaisedStreet4 BOOLEAN,
947 raiseFirstInChance BOOLEAN,
948 raisedFirstIn BOOLEAN,
949 foldBbToStealChance BOOLEAN,
950 foldedBbToSteal BOOLEAN,
951 foldSbToStealChance BOOLEAN,
952 foldedSbToSteal BOOLEAN,
954 street1CBChance BOOLEAN,
955 street1CBDone BOOLEAN,
956 street2CBChance BOOLEAN,
957 street2CBDone BOOLEAN,
958 street3CBChance BOOLEAN,
959 street3CBDone BOOLEAN,
960 street4CBChance BOOLEAN,
961 street4CBDone BOOLEAN,
963 foldToStreet1CBChance BOOLEAN,
964 foldToStreet1CBDone BOOLEAN,
965 foldToStreet2CBChance BOOLEAN,
966 foldToStreet2CBDone BOOLEAN,
967 foldToStreet3CBChance BOOLEAN,
968 foldToStreet3CBDone BOOLEAN,
969 foldToStreet4CBChance BOOLEAN,
970 foldToStreet4CBDone BOOLEAN,
972 street1CheckCallRaiseChance BOOLEAN,
973 street1CheckCallDone BOOLEAN,
974 street1CheckRaiseDone BOOLEAN,
975 street2CheckCallRaiseChance BOOLEAN,
976 street2CheckCallDone BOOLEAN,
977 street2CheckRaiseDone BOOLEAN,
978 street3CheckCallRaiseChance BOOLEAN,
979 street3CheckCallDone BOOLEAN,
980 street3CheckRaiseDone BOOLEAN,
981 street4CheckCallRaiseChance BOOLEAN,
982 street4CheckCallDone BOOLEAN,
983 street4CheckRaiseDone BOOLEAN,
985 street0Calls TINYINT,
986 street1Calls TINYINT,
987 street2Calls TINYINT,
988 street3Calls TINYINT,
989 street4Calls TINYINT,
990 street0Bets TINYINT,
991 street1Bets TINYINT,
992 street2Bets TINYINT,
993 street3Bets TINYINT,
994 street4Bets TINYINT,
995 street0Raises TINYINT,
996 street1Raises TINYINT,
997 street2Raises TINYINT,
998 street3Raises TINYINT,
999 street4Raises TINYINT,
1000 street1Discards TINYINT,
1001 street2Discards TINYINT,
1002 street3Discards TINYINT,
1004 handString TEXT,
1005 actionString VARCHAR(15))
1006 ENGINE=INNODB"""
1007 elif db_server == 'postgresql':
1008 self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
1009 id BIGSERIAL, PRIMARY KEY (id),
1010 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1011 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1012 startCash BIGINT NOT NULL,
1013 effStack BIGINT NOT NULL,
1014 startBounty BIGINT,
1015 endBounty BIGINT,
1016 position CHAR(1),
1017 seatNo SMALLINT NOT NULL,
1018 sitout BOOLEAN NOT NULL,
1020 card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
1021 card2 smallint NOT NULL,
1022 card3 smallint,
1023 card4 smallint,
1024 card5 smallint,
1025 card6 smallint,
1026 card7 smallint,
1027 card8 smallint, /* cards 8-20 for draw hands */
1028 card9 smallint,
1029 card10 smallint,
1030 card11 smallint,
1031 card12 smallint,
1032 card13 smallint,
1033 card14 smallint,
1034 card15 smallint,
1035 card16 smallint,
1036 card17 smallint,
1037 card18 smallint,
1038 card19 smallint,
1039 card20 smallint,
1040 startCards smallint, FOREIGN KEY (startCards) REFERENCES StartCards(id),
1042 common BIGINT NOT NULL,
1043 committed BIGINT NOT NULL,
1044 winnings BIGINT NOT NULL,
1045 rake BIGINT NOT NULL,
1046 rakeDealt NUMERIC NOT NULL,
1047 rakeContributed NUMERIC NOT NULL,
1048 rakeWeighted NUMERIC NOT NULL,
1049 totalProfit BIGINT,
1050 allInEV NUMERIC,
1051 comment text,
1052 commentTs timestamp without time zone,
1053 tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id),
1055 wonWhenSeenStreet1 BOOLEAN,
1056 wonWhenSeenStreet2 BOOLEAN,
1057 wonWhenSeenStreet3 BOOLEAN,
1058 wonWhenSeenStreet4 BOOLEAN,
1059 wonAtSD BOOLEAN,
1061 street0VPIChance BOOLEAN,
1062 street0VPI BOOLEAN,
1063 street0AggrChance BOOLEAN,
1064 street0Aggr BOOLEAN,
1065 street0CalledRaiseChance SMALLINT,
1066 street0CalledRaiseDone SMALLINT,
1067 street0_2BChance BOOLEAN,
1068 street0_2BDone BOOLEAN,
1069 street0_3BChance BOOLEAN,
1070 street0_3BDone BOOLEAN,
1071 street0_4BChance BOOLEAN,
1072 street0_4BDone BOOLEAN,
1073 street0_C4BChance BOOLEAN,
1074 street0_C4BDone BOOLEAN,
1075 street0_FoldTo2BChance BOOLEAN,
1076 street0_FoldTo2BDone BOOLEAN,
1077 street0_FoldTo3BChance BOOLEAN,
1078 street0_FoldTo3BDone BOOLEAN,
1079 street0_FoldTo4BChance BOOLEAN,
1080 street0_FoldTo4BDone BOOLEAN,
1081 street0_SqueezeChance BOOLEAN,
1082 street0_SqueezeDone BOOLEAN,
1084 raiseToStealChance BOOLEAN,
1085 raiseToStealDone BOOLEAN,
1086 stealChance BOOLEAN,
1087 stealDone BOOLEAN,
1088 success_Steal BOOLEAN,
1090 street1Seen BOOLEAN,
1091 street2Seen BOOLEAN,
1092 street3Seen BOOLEAN,
1093 street4Seen BOOLEAN,
1094 sawShowdown BOOLEAN,
1095 showed BOOLEAN,
1097 street0AllIn BOOLEAN,
1098 street1AllIn BOOLEAN,
1099 street2AllIn BOOLEAN,
1100 street3AllIn BOOLEAN,
1101 street4AllIn BOOLEAN,
1102 wentAllIn BOOLEAN,
1104 street0InPosition BOOLEAN,
1105 street1InPosition BOOLEAN,
1106 street2InPosition BOOLEAN,
1107 street3InPosition BOOLEAN,
1108 street4InPosition BOOLEAN,
1109 street0FirstToAct BOOLEAN,
1110 street1FirstToAct BOOLEAN,
1111 street2FirstToAct BOOLEAN,
1112 street3FirstToAct BOOLEAN,
1113 street4FirstToAct BOOLEAN,
1115 street1Aggr BOOLEAN,
1116 street2Aggr BOOLEAN,
1117 street3Aggr BOOLEAN,
1118 street4Aggr BOOLEAN,
1120 otherRaisedStreet0 BOOLEAN,
1121 otherRaisedStreet1 BOOLEAN,
1122 otherRaisedStreet2 BOOLEAN,
1123 otherRaisedStreet3 BOOLEAN,
1124 otherRaisedStreet4 BOOLEAN,
1125 foldToOtherRaisedStreet0 BOOLEAN,
1126 foldToOtherRaisedStreet1 BOOLEAN,
1127 foldToOtherRaisedStreet2 BOOLEAN,
1128 foldToOtherRaisedStreet3 BOOLEAN,
1129 foldToOtherRaisedStreet4 BOOLEAN,
1131 raiseFirstInChance BOOLEAN,
1132 raisedFirstIn BOOLEAN,
1133 foldBbToStealChance BOOLEAN,
1134 foldedBbToSteal BOOLEAN,
1135 foldSbToStealChance BOOLEAN,
1136 foldedSbToSteal BOOLEAN,
1138 street1CBChance BOOLEAN,
1139 street1CBDone BOOLEAN,
1140 street2CBChance BOOLEAN,
1141 street2CBDone BOOLEAN,
1142 street3CBChance BOOLEAN,
1143 street3CBDone BOOLEAN,
1144 street4CBChance BOOLEAN,
1145 street4CBDone BOOLEAN,
1147 foldToStreet1CBChance BOOLEAN,
1148 foldToStreet1CBDone BOOLEAN,
1149 foldToStreet2CBChance BOOLEAN,
1150 foldToStreet2CBDone BOOLEAN,
1151 foldToStreet3CBChance BOOLEAN,
1152 foldToStreet3CBDone BOOLEAN,
1153 foldToStreet4CBChance BOOLEAN,
1154 foldToStreet4CBDone BOOLEAN,
1156 street1CheckCallRaiseChance BOOLEAN,
1157 street1CheckCallDone BOOLEAN,
1158 street1CheckRaiseDone BOOLEAN,
1159 street2CheckCallRaiseChance BOOLEAN,
1160 street2CheckCallDone BOOLEAN,
1161 street2CheckRaiseDone BOOLEAN,
1162 street3CheckCallRaiseChance BOOLEAN,
1163 street3CheckCallDone BOOLEAN,
1164 street3CheckRaiseDone BOOLEAN,
1165 street4CheckCallRaiseChance BOOLEAN,
1166 street4CheckCallDone BOOLEAN,
1167 street4CheckRaiseDone BOOLEAN,
1169 street0Calls SMALLINT,
1170 street1Calls SMALLINT,
1171 street2Calls SMALLINT,
1172 street3Calls SMALLINT,
1173 street4Calls SMALLINT,
1174 street0Bets SMALLINT,
1175 street1Bets SMALLINT,
1176 street2Bets SMALLINT,
1177 street3Bets SMALLINT,
1178 street4Bets SMALLINT,
1179 street0Raises SMALLINT,
1180 street1Raises SMALLINT,
1181 street2Raises SMALLINT,
1182 street3Raises SMALLINT,
1183 street4Raises SMALLINT,
1184 street1Discards SMALLINT,
1185 street2Discards SMALLINT,
1186 street3Discards SMALLINT,
1188 handString TEXT,
1189 actionString VARCHAR(15))"""
1190 elif db_server == 'sqlite':
1191 self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
1192 id INTEGER PRIMARY KEY,
1193 handId INT NOT NULL,
1194 playerId INT NOT NULL,
1195 startCash INT NOT NULL,
1196 effStack INT NOT NULL,
1197 startBounty INT,
1198 endBounty INT,
1199 position TEXT,
1200 seatNo INT NOT NULL,
1201 sitout BOOLEAN NOT NULL,
1203 card1 INT NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
1204 card2 INT NOT NULL,
1205 card3 INT,
1206 card4 INT,
1207 card5 INT,
1208 card6 INT,
1209 card7 INT,
1210 card8 INT, /* cards 8-20 for draw hands */
1211 card9 INT,
1212 card10 INT,
1213 card11 INT,
1214 card12 INT,
1215 card13 INT,
1216 card14 INT,
1217 card15 INT,
1218 card16 INT,
1219 card17 INT,
1220 card18 INT,
1221 card19 INT,
1222 card20 INT,
1223 startCards INT,
1225 common INT NOT NULL,
1226 committed INT NOT NULL,
1227 winnings INT NOT NULL,
1228 rake INT NOT NULL,
1229 rakeDealt decimal NOT NULL,
1230 rakeContributed decimal NOT NULL,
1231 rakeWeighted decimal NOT NULL,
1232 totalProfit INT,
1233 allInEV decimal,
1234 comment TEXT,
1235 commentTs timestamp,
1236 tourneysPlayersId INT,
1238 wonWhenSeenStreet1 INT,
1239 wonWhenSeenStreet2 INT,
1240 wonWhenSeenStreet3 INT,
1241 wonWhenSeenStreet4 INT,
1242 wonAtSD INT,
1244 street0VPIChance INT,
1245 street0VPI INT,
1246 street0AggrChance INT,
1247 street0Aggr INT,
1248 street0CalledRaiseChance INT,
1249 street0CalledRaiseDone INT,
1250 street0_2BChance INT,
1251 street0_2BDone INT,
1252 street0_3BChance INT,
1253 street0_3BDone INT,
1254 street0_4BChance INT,
1255 street0_4BDone INT,
1256 street0_C4BChance INT,
1257 street0_C4BDone INT,
1258 street0_FoldTo2BChance INT,
1259 street0_FoldTo2BDone INT,
1260 street0_FoldTo3BChance INT,
1261 street0_FoldTo3BDone INT,
1262 street0_FoldTo4BChance INT,
1263 street0_FoldTo4BDone INT,
1264 street0_SqueezeChance INT,
1265 street0_SqueezeDone INT,
1267 raiseToStealChance INT,
1268 raiseToStealDone INT,
1269 stealChance INT,
1270 stealDone INT,
1271 success_Steal INT,
1273 street1Seen INT,
1274 street2Seen INT,
1275 street3Seen INT,
1276 street4Seen INT,
1277 sawShowdown INT,
1278 showed INT,
1280 street0AllIn INT,
1281 street1AllIn INT,
1282 street2AllIn INT,
1283 street3AllIn INT,
1284 street4AllIn INT,
1285 wentAllIn INT,
1287 street0InPosition INT,
1288 street1InPosition INT,
1289 street2InPosition INT,
1290 street3InPosition INT,
1291 street4InPosition INT,
1292 street0FirstToAct INT,
1293 street1FirstToAct INT,
1294 street2FirstToAct INT,
1295 street3FirstToAct INT,
1296 street4FirstToAct INT,
1298 street1Aggr INT,
1299 street2Aggr INT,
1300 street3Aggr INT,
1301 street4Aggr INT,
1303 otherRaisedStreet0 INT,
1304 otherRaisedStreet1 INT,
1305 otherRaisedStreet2 INT,
1306 otherRaisedStreet3 INT,
1307 otherRaisedStreet4 INT,
1308 foldToOtherRaisedStreet0 INT,
1309 foldToOtherRaisedStreet1 INT,
1310 foldToOtherRaisedStreet2 INT,
1311 foldToOtherRaisedStreet3 INT,
1312 foldToOtherRaisedStreet4 INT,
1314 raiseFirstInChance INT,
1315 raisedFirstIn INT,
1316 foldBbToStealChance INT,
1317 foldedBbToSteal INT,
1318 foldSbToStealChance INT,
1319 foldedSbToSteal INT,
1321 street1CBChance INT,
1322 street1CBDone INT,
1323 street2CBChance INT,
1324 street2CBDone INT,
1325 street3CBChance INT,
1326 street3CBDone INT,
1327 street4CBChance INT,
1328 street4CBDone INT,
1330 foldToStreet1CBChance INT,
1331 foldToStreet1CBDone INT,
1332 foldToStreet2CBChance INT,
1333 foldToStreet2CBDone INT,
1334 foldToStreet3CBChance INT,
1335 foldToStreet3CBDone INT,
1336 foldToStreet4CBChance INT,
1337 foldToStreet4CBDone INT,
1339 street1CheckCallRaiseChance INT,
1340 street1CheckCallDone INT,
1341 street1CheckRaiseDone INT,
1342 street2CheckCallRaiseChance INT,
1343 street2CheckCallDone INT,
1344 street2CheckRaiseDone INT,
1345 street3CheckCallRaiseChance INT,
1346 street3CheckCallDone INT,
1347 street3CheckRaiseDone INT,
1348 street4CheckCallRaiseChance INT,
1349 street4CheckCallDone INT,
1350 street4CheckRaiseDone INT,
1352 street0Calls INT,
1353 street1Calls INT,
1354 street2Calls INT,
1355 street3Calls INT,
1356 street4Calls INT,
1357 street0Bets INT,
1358 street1Bets INT,
1359 street2Bets INT,
1360 street3Bets INT,
1361 street4Bets INT,
1362 street0Raises INT,
1363 street1Raises INT,
1364 street2Raises INT,
1365 street3Raises INT,
1366 street4Raises INT,
1367 street1Discards INT,
1368 street2Discards INT,
1369 street3Discards INT,
1371 handString TEXT,
1372 actionString VARCHAR(15))
1373 """
1376 ################################
1377 # Create TourneysPlayers
1378 ################################
1380 if db_server == 'mysql':
1381 self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
1382 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1383 tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
1384 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1385 entryId INT,
1386 rank INT,
1387 winnings BIGINT,
1388 winningsCurrency VARCHAR(4),
1389 rebuyCount INT,
1390 addOnCount INT,
1391 koCount NUMERIC,
1392 comment TEXT,
1393 commentTs DATETIME)
1394 ENGINE=INNODB"""
1395 elif db_server == 'postgresql':
1396 self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
1397 id BIGSERIAL, PRIMARY KEY (id),
1398 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
1399 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
1400 entryId INT,
1401 rank INT,
1402 winnings BIGINT,
1403 winningsCurrency VARCHAR(4),
1404 rebuyCount INT,
1405 addOnCount INT,
1406 koCount NUMERIC,
1407 comment TEXT,
1408 commentTs timestamp without time zone)"""
1409 elif db_server == 'sqlite':
1410 self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
1411 id INTEGER PRIMARY KEY,
1412 tourneyId INT,
1413 playerId INT,
1414 entryId INT,
1415 rank INT,
1416 winnings INT,
1417 winningsCurrency VARCHAR(4),
1418 rebuyCount INT,
1419 addOnCount INT,
1420 koCount decimal,
1421 comment TEXT,
1422 commentTs timestamp,
1423 FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
1424 FOREIGN KEY (playerId) REFERENCES Players(id)
1425 )"""
1428 ################################
1429 # Create HandsActions
1430 ################################
1432 if db_server == 'mysql':
1433 self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
1434 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1435 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1436 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1437 street SMALLINT NOT NULL,
1438 actionNo SMALLINT NOT NULL,
1439 streetActionNo SMALLINT NOT NULL,
1440 actionId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (actionId) REFERENCES Actions(id),
1441 amount BIGINT NOT NULL,
1442 raiseTo BIGINT NOT NULL,
1443 amountCalled BIGINT NOT NULL,
1444 numDiscarded SMALLINT NOT NULL,
1445 cardsDiscarded varchar(14),
1446 allIn BOOLEAN NOT NULL)
1447 ENGINE=INNODB"""
1448 elif db_server == 'postgresql':
1449 self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
1450 id BIGSERIAL, PRIMARY KEY (id),
1451 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1452 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1453 street SMALLINT,
1454 actionNo SMALLINT,
1455 streetActionNo SMALLINT,
1456 actionId SMALLINT, FOREIGN KEY (actionId) REFERENCES Actions(id),
1457 amount BIGINT,
1458 raiseTo BIGINT,
1459 amountCalled BIGINT,
1460 numDiscarded SMALLINT,
1461 cardsDiscarded varchar(14),
1462 allIn BOOLEAN)"""
1463 elif db_server == 'sqlite':
1464 self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
1465 id INTEGER PRIMARY KEY,
1466 handId INT NOT NULL,
1467 playerId INT NOT NULL,
1468 street SMALLINT,
1469 actionNo SMALLINT,
1470 streetActionNo SMALLINT,
1471 actionId SMALLINT,
1472 amount INT,
1473 raiseTo INT,
1474 amountCalled INT,
1475 numDiscarded SMALLINT,
1476 cardsDiscarded TEXT,
1477 allIn BOOLEAN
1478 )"""
1481 ################################
1482 # Create HandsStove
1483 ################################
1485 if db_server == 'mysql':
1486 self.query['createHandsStoveTable'] = """CREATE TABLE HandsStove (
1487 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1488 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1489 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1490 streetId SMALLINT,
1491 boardId SMALLINT,
1492 hiLo char(1) NOT NULL,
1493 rankId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (rankId) REFERENCES Rank(id),
1494 value BIGINT,
1495 cards VARCHAR(5),
1496 ev NUMERIC)
1497 ENGINE=INNODB"""
1498 elif db_server == 'postgresql':
1499 self.query['createHandsStoveTable'] = """CREATE TABLE HandsStove (
1500 id BIGSERIAL, PRIMARY KEY (id),
1501 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1502 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1503 streetId SMALLINT,
1504 boardId SMALLINT,
1505 hiLo char(1) NOT NULL,
1506 rankId SMALLINT NOT NULL, FOREIGN KEY (rankId) REFERENCES Rank(id),
1507 value BIGINT,
1508 cards VARCHAR(5),
1509 ev NUMERIC)"""
1510 elif db_server == 'sqlite':
1511 self.query['createHandsStoveTable'] = """CREATE TABLE HandsStove (
1512 id INTEGER PRIMARY KEY,
1513 handId INT NOT NULL,
1514 playerId INT NOT NULL,
1515 streetId INT,
1516 boardId INT,
1517 hiLo TEXT NOT NULL,
1518 rankId INT,
1519 value INT,
1520 cards TEXT,
1521 ev decimal
1522 )"""
1524 ################################
1525 # Create HandsPots
1526 ################################
1528 if db_server == 'mysql':
1529 self.query['createHandsPotsTable'] = """CREATE TABLE HandsPots (
1530 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1531 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1532 potId SMALLINT,
1533 boardId SMALLINT,
1534 hiLo char(1) NOT NULL,
1535 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1536 pot BIGINT,
1537 collected BIGINT,
1538 rake INT)
1539 ENGINE=INNODB"""
1540 elif db_server == 'postgresql':
1541 self.query['createHandsPotsTable'] = """CREATE TABLE HandsPots (
1542 id BIGSERIAL, PRIMARY KEY (id),
1543 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
1544 potId SMALLINT,
1545 boardId SMALLINT,
1546 hiLo char(1) NOT NULL,
1547 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1548 pot BIGINT,
1549 collected BIGINT,
1550 rake INT)"""
1551 elif db_server == 'sqlite':
1552 self.query['createHandsPotsTable'] = """CREATE TABLE HandsPots (
1553 id INTEGER PRIMARY KEY,
1554 handId INT NOT NULL,
1555 potId INT,
1556 boardId INT,
1557 hiLo TEXT NOT NULL,
1558 playerId INT NOT NULL,
1559 pot INT,
1560 collected INT,
1561 rake INT
1562 )"""
1564 ################################
1565 # Create Files
1566 ################################
1568 if db_server == 'mysql':
1569 self.query['createFilesTable'] = """CREATE TABLE Files (
1570 id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1571 file text NOT NULL,
1572 site VARCHAR(32),
1573 type VARCHAR(7),
1574 startTime DATETIME NOT NULL,
1575 lastUpdate DATETIME NOT NULL,
1576 endTime DATETIME,
1577 hands INT,
1578 storedHands INT,
1579 dups INT,
1580 partial INT,
1581 skipped INT,
1582 errs INT,
1583 ttime100 INT,
1584 finished BOOLEAN)
1585 ENGINE=INNODB"""
1586 elif db_server == 'postgresql':
1587 self.query['createFilesTable'] = """CREATE TABLE Files (
1588 id BIGSERIAL, PRIMARY KEY (id),
1589 file TEXT NOT NULL,
1590 site VARCHAR(32),
1591 type VARCHAR(7),
1592 startTime timestamp without time zone NOT NULL,
1593 lastUpdate timestamp without time zone NOT NULL,
1594 endTime timestamp without time zone,
1595 hands INT,
1596 storedHands INT,
1597 dups INT,
1598 partial INT,
1599 skipped INT,
1600 errs INT,
1601 ttime100 INT,
1602 finished BOOLEAN)"""
1603 elif db_server == 'sqlite':
1604 self.query['createFilesTable'] = """CREATE TABLE Files (
1605 id INTEGER PRIMARY KEY,
1606 file TEXT NOT NULL,
1607 site VARCHAR(32),
1608 type VARCHAR(7),
1609 startTime timestamp NOT NULL,
1610 lastUpdate timestamp NOT NULL,
1611 endTime timestamp,
1612 hands INT,
1613 storedHands INT,
1614 dups INT,
1615 partial INT,
1616 skipped INT,
1617 errs INT,
1618 ttime100 INT,
1619 finished BOOLEAN
1620 )"""
1622 ################################
1623 # Create HudCache
1624 ################################
1626 if db_server == 'mysql':
1627 self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
1628 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
1629 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
1630 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
1631 seats SMALLINT NOT NULL,
1632 position CHAR(1),
1633 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
1634 styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
1635 n INT NOT NULL,
1636 street0VPIChance INT,
1637 street0VPI INT,
1638 street0AggrChance INT,
1639 street0Aggr INT,
1640 street0CalledRaiseChance INT,
1641 street0CalledRaiseDone INT,
1642 street0_2BChance INT,
1643 street0_2BDone INT,
1644 street0_3BChance INT,
1645 street0_3BDone INT,
1646 street0_4BChance INT,
1647 street0_4BDone INT,
1648 street0_C4BChance INT,
1649 street0_C4BDone INT,
1650 street0_FoldTo2BChance INT,
1651 street0_FoldTo2BDone INT,
1652 street0_FoldTo3BChance INT,
1653 street0_FoldTo3BDone INT,
1654 street0_FoldTo4BChance INT,
1655 street0_FoldTo4BDone INT,
1656 street0_SqueezeChance INT,
1657 street0_SqueezeDone INT,
1658 raiseToStealChance INT,
1659 raiseToStealDone INT,
1660 stealChance INT,
1661 stealDone INT,
1662 success_Steal INT,
1663 street1Seen INT,
1664 street2Seen INT,
1665 street3Seen INT,
1666 street4Seen INT,
1667 sawShowdown INT,
1668 street1Aggr INT,
1669 street2Aggr INT,
1670 street3Aggr INT,
1671 street4Aggr INT,
1672 otherRaisedStreet0 INT,
1673 otherRaisedStreet1 INT,
1674 otherRaisedStreet2 INT,
1675 otherRaisedStreet3 INT,
1676 otherRaisedStreet4 INT,
1677 foldToOtherRaisedStreet0 INT,
1678 foldToOtherRaisedStreet1 INT,
1679 foldToOtherRaisedStreet2 INT,
1680 foldToOtherRaisedStreet3 INT,
1681 foldToOtherRaisedStreet4 INT,
1682 wonWhenSeenStreet1 INT,
1683 wonWhenSeenStreet2 INT,
1684 wonWhenSeenStreet3 INT,
1685 wonWhenSeenStreet4 INT,
1686 wonAtSD INT,
1687 raiseFirstInChance INT,
1688 raisedFirstIn INT,
1689 foldBbToStealChance INT,
1690 foldedBbToSteal INT,
1691 foldSbToStealChance INT,
1692 foldedSbToSteal INT,
1693 street1CBChance INT,
1694 street1CBDone INT,
1695 street2CBChance INT,
1696 street2CBDone INT,
1697 street3CBChance INT,
1698 street3CBDone INT,
1699 street4CBChance INT,
1700 street4CBDone INT,
1701 foldToStreet1CBChance INT,
1702 foldToStreet1CBDone INT,
1703 foldToStreet2CBChance INT,
1704 foldToStreet2CBDone INT,
1705 foldToStreet3CBChance INT,
1706 foldToStreet3CBDone INT,
1707 foldToStreet4CBChance INT,
1708 foldToStreet4CBDone INT,
1709 common BIGINT,
1710 committed BIGINT,
1711 winnings BIGINT,
1712 rake BIGINT,
1713 rakeDealt NUMERIC,
1714 rakeContributed NUMERIC,
1715 rakeWeighted NUMERIC,
1716 totalProfit BIGINT,
1717 allInEV NUMERIC,
1718 showdownWinnings BIGINT,
1719 nonShowdownWinnings BIGINT,
1720 street1CheckCallRaiseChance INT,
1721 street1CheckCallDone INT,
1722 street1CheckRaiseDone INT,
1723 street2CheckCallRaiseChance INT,
1724 street2CheckCallDone INT,
1725 street2CheckRaiseDone INT,
1726 street3CheckCallRaiseChance INT,
1727 street3CheckCallDone INT,
1728 street3CheckRaiseDone INT,
1729 street4CheckCallRaiseChance INT,
1730 street4CheckCallDone INT,
1731 street4CheckRaiseDone INT,
1732 street0Calls INT,
1733 street1Calls INT,
1734 street2Calls INT,
1735 street3Calls INT,
1736 street4Calls INT,
1737 street0Bets INT,
1738 street1Bets INT,
1739 street2Bets INT,
1740 street3Bets INT,
1741 street4Bets INT,
1742 street0Raises INT,
1743 street1Raises INT,
1744 street2Raises INT,
1745 street3Raises INT,
1746 street4Raises INT,
1747 street1Discards INT,
1748 street2Discards INT,
1749 street3Discards INT)
1750 ENGINE=INNODB"""
1751 elif db_server == 'postgresql':
1752 self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
1753 id BIGSERIAL, PRIMARY KEY (id),
1754 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
1755 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
1756 seats SMALLINT,
1757 position CHAR(1),
1758 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
1759 styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
1760 n INT,
1761 street0VPIChance INT,
1762 street0VPI INT,
1763 street0AggrChance INT,
1764 street0Aggr INT,
1765 street0CalledRaiseChance INT,
1766 street0CalledRaiseDone INT,
1767 street0_2BChance INT,
1768 street0_2BDone INT,
1769 street0_3BChance INT,
1770 street0_3BDone INT,
1771 street0_4BChance INT,
1772 street0_4BDone INT,
1773 street0_C4BChance INT,
1774 street0_C4BDone INT,
1775 street0_FoldTo2BChance INT,
1776 street0_FoldTo2BDone INT,
1777 street0_FoldTo3BChance INT,
1778 street0_FoldTo3BDone INT,
1779 street0_FoldTo4BChance INT,
1780 street0_FoldTo4BDone INT,
1781 street0_SqueezeChance INT,
1782 street0_SqueezeDone INT,
1783 raiseToStealChance INT,
1784 raiseToStealDone INT,
1785 stealChance INT,
1786 stealDone INT,
1787 success_Steal INT,
1788 street1Seen INT,
1789 street2Seen INT,
1790 street3Seen INT,
1791 street4Seen INT,
1792 sawShowdown INT,
1793 street1Aggr INT,
1794 street2Aggr INT,
1795 street3Aggr INT,
1796 street4Aggr INT,
1797 otherRaisedStreet0 INT,
1798 otherRaisedStreet1 INT,
1799 otherRaisedStreet2 INT,
1800 otherRaisedStreet3 INT,
1801 otherRaisedStreet4 INT,
1802 foldToOtherRaisedStreet0 INT,
1803 foldToOtherRaisedStreet1 INT,
1804 foldToOtherRaisedStreet2 INT,
1805 foldToOtherRaisedStreet3 INT,
1806 foldToOtherRaisedStreet4 INT,
1807 wonWhenSeenStreet1 INT,
1808 wonWhenSeenStreet2 INT,
1809 wonWhenSeenStreet3 INT,
1810 wonWhenSeenStreet4 INT,
1811 wonAtSD INT,
1812 raiseFirstInChance INT,
1813 raisedFirstIn INT,
1814 foldBbToStealChance INT,
1815 foldedBbToSteal INT,
1816 foldSbToStealChance INT,
1817 foldedSbToSteal INT,
1818 street1CBChance INT,
1819 street1CBDone INT,
1820 street2CBChance INT,
1821 street2CBDone INT,
1822 street3CBChance INT,
1823 street3CBDone INT,
1824 street4CBChance INT,
1825 street4CBDone INT,
1826 foldToStreet1CBChance INT,
1827 foldToStreet1CBDone INT,
1828 foldToStreet2CBChance INT,
1829 foldToStreet2CBDone INT,
1830 foldToStreet3CBChance INT,
1831 foldToStreet3CBDone INT,
1832 foldToStreet4CBChance INT,
1833 foldToStreet4CBDone INT,
1834 common BIGINT,
1835 committed BIGINT,
1836 winnings BIGINT,
1837 rake BIGINT,
1838 rakeDealt NUMERIC,
1839 rakeContributed NUMERIC,
1840 rakeWeighted NUMERIC,
1841 totalProfit BIGINT,
1842 allInEV NUMERIC,
1843 showdownWinnings BIGINT,
1844 nonShowdownWinnings BIGINT,
1845 street1CheckCallRaiseChance INT,
1846 street1CheckCallDone INT,
1847 street1CheckRaiseDone INT,
1848 street2CheckCallRaiseChance INT,
1849 street2CheckCallDone INT,
1850 street2CheckRaiseDone INT,
1851 street3CheckCallRaiseChance INT,
1852 street3CheckCallDone INT,
1853 street3CheckRaiseDone INT,
1854 street4CheckCallRaiseChance INT,
1855 street4CheckCallDone INT,
1856 street4CheckRaiseDone INT,
1857 street0Calls INT,
1858 street1Calls INT,
1859 street2Calls INT,
1860 street3Calls INT,
1861 street4Calls INT,
1862 street0Bets INT,
1863 street1Bets INT,
1864 street2Bets INT,
1865 street3Bets INT,
1866 street4Bets INT,
1867 street0Raises INT,
1868 street1Raises INT,
1869 street2Raises INT,
1870 street3Raises INT,
1871 street4Raises INT,
1872 street1Discards INT,
1873 street2Discards INT,
1874 street3Discards INT)
1875 """
1876 elif db_server == 'sqlite':
1877 self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
1878 id INTEGER PRIMARY KEY,
1879 gametypeId INT,
1880 playerId INT,
1881 seats INT,
1882 position TEXT,
1883 tourneyTypeId INT,
1884 styleKey TEXT NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */
1885 n INT,
1886 street0VPIChance INT,
1887 street0VPI INT,
1888 street0AggrChance INT,
1889 street0Aggr INT,
1890 street0CalledRaiseChance INT,
1891 street0CalledRaiseDone INT,
1892 street0_2BChance INT,
1893 street0_2BDone INT,
1894 street0_3BChance INT,
1895 street0_3BDone INT,
1896 street0_4BChance INT,
1897 street0_4BDone INT,
1898 street0_C4BChance INT,
1899 street0_C4BDone INT,
1900 street0_FoldTo2BChance INT,
1901 street0_FoldTo2BDone INT,
1902 street0_FoldTo3BChance INT,
1903 street0_FoldTo3BDone INT,
1904 street0_FoldTo4BChance INT,
1905 street0_FoldTo4BDone INT,
1906 street0_SqueezeChance INT,
1907 street0_SqueezeDone INT,
1908 raiseToStealChance INT,
1909 raiseToStealDone INT,
1910 stealChance INT,
1911 stealDone INT,
1912 success_Steal INT,
1913 street1Seen INT,
1914 street2Seen INT,
1915 street3Seen INT,
1916 street4Seen INT,
1917 sawShowdown INT,
1918 street1Aggr INT,
1919 street2Aggr INT,
1920 street3Aggr INT,
1921 street4Aggr INT,
1922 otherRaisedStreet0 INT,
1923 otherRaisedStreet1 INT,
1924 otherRaisedStreet2 INT,
1925 otherRaisedStreet3 INT,
1926 otherRaisedStreet4 INT,
1927 foldToOtherRaisedStreet0 INT,
1928 foldToOtherRaisedStreet1 INT,
1929 foldToOtherRaisedStreet2 INT,
1930 foldToOtherRaisedStreet3 INT,
1931 foldToOtherRaisedStreet4 INT,
1932 wonWhenSeenStreet1 INT,
1933 wonWhenSeenStreet2 INT,
1934 wonWhenSeenStreet3 INT,
1935 wonWhenSeenStreet4 INT,
1936 wonAtSD INT,
1937 raiseFirstInChance INT,
1938 raisedFirstIn INT,
1939 foldBbToStealChance INT,
1940 foldedBbToSteal INT,
1941 foldSbToStealChance INT,
1942 foldedSbToSteal INT,
1943 street1CBChance INT,
1944 street1CBDone INT,
1945 street2CBChance INT,
1946 street2CBDone INT,
1947 street3CBChance INT,
1948 street3CBDone INT,
1949 street4CBChance INT,
1950 street4CBDone INT,
1951 foldToStreet1CBChance INT,
1952 foldToStreet1CBDone INT,
1953 foldToStreet2CBChance INT,
1954 foldToStreet2CBDone INT,
1955 foldToStreet3CBChance INT,
1956 foldToStreet3CBDone INT,
1957 foldToStreet4CBChance INT,
1958 foldToStreet4CBDone INT,
1959 common INT,
1960 committed INT,
1961 winnings INT,
1962 rake INT,
1963 rakeDealt decimal,
1964 rakeContributed decimal,
1965 rakeWeighted decimal,
1966 totalProfit INT,
1967 allInEV decimal,
1968 showdownWinnings INT,
1969 nonShowdownWinnings INT,
1970 street1CheckCallRaiseChance INT,
1971 street1CheckCallDone INT,
1972 street1CheckRaiseDone INT,
1973 street2CheckCallRaiseChance INT,
1974 street2CheckCallDone INT,
1975 street2CheckRaiseDone INT,
1976 street3CheckCallRaiseChance INT,
1977 street3CheckCallDone INT,
1978 street3CheckRaiseDone INT,
1979 street4CheckCallRaiseChance INT,
1980 street4CheckCallDone INT,
1981 street4CheckRaiseDone INT,
1982 street0Calls INT,
1983 street1Calls INT,
1984 street2Calls INT,
1985 street3Calls INT,
1986 street4Calls INT,
1987 street0Bets INT,
1988 street1Bets INT,
1989 street2Bets INT,
1990 street3Bets INT,
1991 street4Bets INT,
1992 street0Raises INT,
1993 street1Raises INT,
1994 street2Raises INT,
1995 street3Raises INT,
1996 street4Raises INT,
1997 street1Discards INT,
1998 street2Discards INT,
1999 street3Discards INT)
2000 """
2002 ################################
2003 # Create CardsCache
2004 ################################
2006 if db_server == 'mysql':
2007 self.query['createCardsCacheTable'] = """CREATE TABLE CardsCache (
2008 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2009 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2010 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id),
2011 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2012 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
2013 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
2014 startCards SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (startCards) REFERENCES StartCards(id),
2015 n INT NOT NULL,
2016 street0VPIChance INT,
2017 street0VPI INT,
2018 street0AggrChance INT,
2019 street0Aggr INT,
2020 street0CalledRaiseChance INT,
2021 street0CalledRaiseDone INT,
2022 street0_2BChance INT,
2023 street0_2BDone INT,
2024 street0_3BChance INT,
2025 street0_3BDone INT,
2026 street0_4BChance INT,
2027 street0_4BDone INT,
2028 street0_C4BChance INT,
2029 street0_C4BDone INT,
2030 street0_FoldTo2BChance INT,
2031 street0_FoldTo2BDone INT,
2032 street0_FoldTo3BChance INT,
2033 street0_FoldTo3BDone INT,
2034 street0_FoldTo4BChance INT,
2035 street0_FoldTo4BDone INT,
2036 street0_SqueezeChance INT,
2037 street0_SqueezeDone INT,
2038 raiseToStealChance INT,
2039 raiseToStealDone INT,
2040 stealChance INT,
2041 stealDone INT,
2042 success_Steal INT,
2043 street1Seen INT,
2044 street2Seen INT,
2045 street3Seen INT,
2046 street4Seen INT,
2047 sawShowdown INT,
2048 street1Aggr INT,
2049 street2Aggr INT,
2050 street3Aggr INT,
2051 street4Aggr INT,
2052 otherRaisedStreet0 INT,
2053 otherRaisedStreet1 INT,
2054 otherRaisedStreet2 INT,
2055 otherRaisedStreet3 INT,
2056 otherRaisedStreet4 INT,
2057 foldToOtherRaisedStreet0 INT,
2058 foldToOtherRaisedStreet1 INT,
2059 foldToOtherRaisedStreet2 INT,
2060 foldToOtherRaisedStreet3 INT,
2061 foldToOtherRaisedStreet4 INT,
2062 wonWhenSeenStreet1 INT,
2063 wonWhenSeenStreet2 INT,
2064 wonWhenSeenStreet3 INT,
2065 wonWhenSeenStreet4 INT,
2066 wonAtSD INT,
2067 raiseFirstInChance INT,
2068 raisedFirstIn INT,
2069 foldBbToStealChance INT,
2070 foldedBbToSteal INT,
2071 foldSbToStealChance INT,
2072 foldedSbToSteal INT,
2073 street1CBChance INT,
2074 street1CBDone INT,
2075 street2CBChance INT,
2076 street2CBDone INT,
2077 street3CBChance INT,
2078 street3CBDone INT,
2079 street4CBChance INT,
2080 street4CBDone INT,
2081 foldToStreet1CBChance INT,
2082 foldToStreet1CBDone INT,
2083 foldToStreet2CBChance INT,
2084 foldToStreet2CBDone INT,
2085 foldToStreet3CBChance INT,
2086 foldToStreet3CBDone INT,
2087 foldToStreet4CBChance INT,
2088 foldToStreet4CBDone INT,
2089 common BIGINT,
2090 committed BIGINT,
2091 winnings BIGINT,
2092 rake BIGINT,
2093 rakeDealt NUMERIC,
2094 rakeContributed NUMERIC,
2095 rakeWeighted NUMERIC,
2096 totalProfit BIGINT,
2097 allInEV NUMERIC,
2098 showdownWinnings BIGINT,
2099 nonShowdownWinnings BIGINT,
2100 street1CheckCallRaiseChance INT,
2101 street1CheckCallDone INT,
2102 street1CheckRaiseDone INT,
2103 street2CheckCallRaiseChance INT,
2104 street2CheckCallDone INT,
2105 street2CheckRaiseDone INT,
2106 street3CheckCallRaiseChance INT,
2107 street3CheckCallDone INT,
2108 street3CheckRaiseDone INT,
2109 street4CheckCallRaiseChance INT,
2110 street4CheckCallDone INT,
2111 street4CheckRaiseDone INT,
2112 street0Calls INT,
2113 street1Calls INT,
2114 street2Calls INT,
2115 street3Calls INT,
2116 street4Calls INT,
2117 street0Bets INT,
2118 street1Bets INT,
2119 street2Bets INT,
2120 street3Bets INT,
2121 street4Bets INT,
2122 street0Raises INT,
2123 street1Raises INT,
2124 street2Raises INT,
2125 street3Raises INT,
2126 street4Raises INT,
2127 street1Discards INT,
2128 street2Discards INT,
2129 street3Discards INT)
2130 ENGINE=INNODB"""
2131 elif db_server == 'postgresql':
2132 self.query['createCardsCacheTable'] = """CREATE TABLE CardsCache (
2133 id BIGSERIAL, PRIMARY KEY (id),
2134 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2135 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id),
2136 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2137 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
2138 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
2139 startCards SMALLINT, FOREIGN KEY (startCards) REFERENCES StartCards(id),
2140 n INT,
2141 street0VPIChance INT,
2142 street0VPI INT,
2143 street0AggrChance INT,
2144 street0Aggr INT,
2145 street0CalledRaiseChance INT,
2146 street0CalledRaiseDone INT,
2147 street0_2BChance INT,
2148 street0_2BDone INT,
2149 street0_3BChance INT,
2150 street0_3BDone INT,
2151 street0_4BChance INT,
2152 street0_4BDone INT,
2153 street0_C4BChance INT,
2154 street0_C4BDone INT,
2155 street0_FoldTo2BChance INT,
2156 street0_FoldTo2BDone INT,
2157 street0_FoldTo3BChance INT,
2158 street0_FoldTo3BDone INT,
2159 street0_FoldTo4BChance INT,
2160 street0_FoldTo4BDone INT,
2161 street0_SqueezeChance INT,
2162 street0_SqueezeDone INT,
2163 raiseToStealChance INT,
2164 raiseToStealDone INT,
2165 stealChance INT,
2166 stealDone INT,
2167 success_Steal INT,
2168 street1Seen INT,
2169 street2Seen INT,
2170 street3Seen INT,
2171 street4Seen INT,
2172 sawShowdown INT,
2173 street1Aggr INT,
2174 street2Aggr INT,
2175 street3Aggr INT,
2176 street4Aggr INT,
2177 otherRaisedStreet0 INT,
2178 otherRaisedStreet1 INT,
2179 otherRaisedStreet2 INT,
2180 otherRaisedStreet3 INT,
2181 otherRaisedStreet4 INT,
2182 foldToOtherRaisedStreet0 INT,
2183 foldToOtherRaisedStreet1 INT,
2184 foldToOtherRaisedStreet2 INT,
2185 foldToOtherRaisedStreet3 INT,
2186 foldToOtherRaisedStreet4 INT,
2187 wonWhenSeenStreet1 INT,
2188 wonWhenSeenStreet2 INT,
2189 wonWhenSeenStreet3 INT,
2190 wonWhenSeenStreet4 INT,
2191 wonAtSD INT,
2192 raiseFirstInChance INT,
2193 raisedFirstIn INT,
2194 foldBbToStealChance INT,
2195 foldedBbToSteal INT,
2196 foldSbToStealChance INT,
2197 foldedSbToSteal INT,
2198 street1CBChance INT,
2199 street1CBDone INT,
2200 street2CBChance INT,
2201 street2CBDone INT,
2202 street3CBChance INT,
2203 street3CBDone INT,
2204 street4CBChance INT,
2205 street4CBDone INT,
2206 foldToStreet1CBChance INT,
2207 foldToStreet1CBDone INT,
2208 foldToStreet2CBChance INT,
2209 foldToStreet2CBDone INT,
2210 foldToStreet3CBChance INT,
2211 foldToStreet3CBDone INT,
2212 foldToStreet4CBChance INT,
2213 foldToStreet4CBDone INT,
2214 common BIGINT,
2215 committed BIGINT,
2216 winnings BIGINT,
2217 rake BIGINT,
2218 rakeDealt NUMERIC,
2219 rakeContributed NUMERIC,
2220 rakeWeighted NUMERIC,
2221 totalProfit BIGINT,
2222 allInEV NUMERIC,
2223 showdownWinnings BIGINT,
2224 nonShowdownWinnings BIGINT,
2225 street1CheckCallRaiseChance INT,
2226 street1CheckCallDone INT,
2227 street1CheckRaiseDone INT,
2228 street2CheckCallRaiseChance INT,
2229 street2CheckCallDone INT,
2230 street2CheckRaiseDone INT,
2231 street3CheckCallRaiseChance INT,
2232 street3CheckCallDone INT,
2233 street3CheckRaiseDone INT,
2234 street4CheckCallRaiseChance INT,
2235 street4CheckCallDone INT,
2236 street4CheckRaiseDone INT,
2237 street0Calls INT,
2238 street1Calls INT,
2239 street2Calls INT,
2240 street3Calls INT,
2241 street4Calls INT,
2242 street0Bets INT,
2243 street1Bets INT,
2244 street2Bets INT,
2245 street3Bets INT,
2246 street4Bets INT,
2247 street0Raises INT,
2248 street1Raises INT,
2249 street2Raises INT,
2250 street3Raises INT,
2251 street4Raises INT,
2252 street1Discards INT,
2253 street2Discards INT,
2254 street3Discards INT)
2255 """
2256 elif db_server == 'sqlite':
2257 self.query['createCardsCacheTable'] = """CREATE TABLE CardsCache (
2258 id INTEGER PRIMARY KEY,
2259 weekId INT,
2260 monthId INT,
2261 gametypeId INT,
2262 tourneyTypeId INT,
2263 playerId INT,
2264 startCards INT,
2265 n INT,
2266 street0VPIChance INT,
2267 street0VPI INT,
2268 street0AggrChance INT,
2269 street0Aggr INT,
2270 street0CalledRaiseChance INT,
2271 street0CalledRaiseDone INT,
2272 street0_2BChance INT,
2273 street0_2BDone INT,
2274 street0_3BChance INT,
2275 street0_3BDone INT,
2276 street0_4BChance INT,
2277 street0_4BDone INT,
2278 street0_C4BChance INT,
2279 street0_C4BDone INT,
2280 street0_FoldTo2BChance INT,
2281 street0_FoldTo2BDone INT,
2282 street0_FoldTo3BChance INT,
2283 street0_FoldTo3BDone INT,
2284 street0_FoldTo4BChance INT,
2285 street0_FoldTo4BDone INT,
2286 street0_SqueezeChance INT,
2287 street0_SqueezeDone INT,
2288 raiseToStealChance INT,
2289 raiseToStealDone INT,
2290 stealChance INT,
2291 stealDone INT,
2292 success_Steal INT,
2293 street1Seen INT,
2294 street2Seen INT,
2295 street3Seen INT,
2296 street4Seen INT,
2297 sawShowdown INT,
2298 street1Aggr INT,
2299 street2Aggr INT,
2300 street3Aggr INT,
2301 street4Aggr INT,
2302 otherRaisedStreet0 INT,
2303 otherRaisedStreet1 INT,
2304 otherRaisedStreet2 INT,
2305 otherRaisedStreet3 INT,
2306 otherRaisedStreet4 INT,
2307 foldToOtherRaisedStreet0 INT,
2308 foldToOtherRaisedStreet1 INT,
2309 foldToOtherRaisedStreet2 INT,
2310 foldToOtherRaisedStreet3 INT,
2311 foldToOtherRaisedStreet4 INT,
2312 wonWhenSeenStreet1 INT,
2313 wonWhenSeenStreet2 INT,
2314 wonWhenSeenStreet3 INT,
2315 wonWhenSeenStreet4 INT,
2316 wonAtSD INT,
2317 raiseFirstInChance INT,
2318 raisedFirstIn INT,
2319 foldBbToStealChance INT,
2320 foldedBbToSteal INT,
2321 foldSbToStealChance INT,
2322 foldedSbToSteal INT,
2323 street1CBChance INT,
2324 street1CBDone INT,
2325 street2CBChance INT,
2326 street2CBDone INT,
2327 street3CBChance INT,
2328 street3CBDone INT,
2329 street4CBChance INT,
2330 street4CBDone INT,
2331 foldToStreet1CBChance INT,
2332 foldToStreet1CBDone INT,
2333 foldToStreet2CBChance INT,
2334 foldToStreet2CBDone INT,
2335 foldToStreet3CBChance INT,
2336 foldToStreet3CBDone INT,
2337 foldToStreet4CBChance INT,
2338 foldToStreet4CBDone INT,
2339 common INT,
2340 committed INT,
2341 winnings INT,
2342 rake INT,
2343 rakeDealt decimal,
2344 rakeContributed decimal,
2345 rakeWeighted decimal,
2346 totalProfit INT,
2347 allInEV decimal,
2348 showdownWinnings INT,
2349 nonShowdownWinnings INT,
2350 street1CheckCallRaiseChance INT,
2351 street1CheckCallDone INT,
2352 street1CheckRaiseDone INT,
2353 street2CheckCallRaiseChance INT,
2354 street2CheckCallDone INT,
2355 street2CheckRaiseDone INT,
2356 street3CheckCallRaiseChance INT,
2357 street3CheckCallDone INT,
2358 street3CheckRaiseDone INT,
2359 street4CheckCallRaiseChance INT,
2360 street4CheckCallDone INT,
2361 street4CheckRaiseDone INT,
2362 street0Calls INT,
2363 street1Calls INT,
2364 street2Calls INT,
2365 street3Calls INT,
2366 street4Calls INT,
2367 street0Bets INT,
2368 street1Bets INT,
2369 street2Bets INT,
2370 street3Bets INT,
2371 street4Bets INT,
2372 street0Raises INT,
2373 street1Raises INT,
2374 street2Raises INT,
2375 street3Raises INT,
2376 street4Raises INT,
2377 street1Discards INT,
2378 street2Discards INT,
2379 street3Discards INT)
2380 """
2382 ################################
2383 # Create PositionsCache
2384 ################################
2386 if db_server == 'mysql':
2387 self.query['createPositionsCacheTable'] = """CREATE TABLE PositionsCache (
2388 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2389 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2390 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id),
2391 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2392 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
2393 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
2394 seats SMALLINT NOT NULL,
2395 maxPosition TINYINT NOT NULL,
2396 position CHAR(1),
2397 n INT NOT NULL,
2398 street0VPIChance INT,
2399 street0VPI INT,
2400 street0AggrChance INT,
2401 street0Aggr INT,
2402 street0CalledRaiseChance INT,
2403 street0CalledRaiseDone INT,
2404 street0_2BChance INT,
2405 street0_2BDone INT,
2406 street0_3BChance INT,
2407 street0_3BDone INT,
2408 street0_4BChance INT,
2409 street0_4BDone INT,
2410 street0_C4BChance INT,
2411 street0_C4BDone INT,
2412 street0_FoldTo2BChance INT,
2413 street0_FoldTo2BDone INT,
2414 street0_FoldTo3BChance INT,
2415 street0_FoldTo3BDone INT,
2416 street0_FoldTo4BChance INT,
2417 street0_FoldTo4BDone INT,
2418 street0_SqueezeChance INT,
2419 street0_SqueezeDone INT,
2420 raiseToStealChance INT,
2421 raiseToStealDone INT,
2422 stealChance INT,
2423 stealDone INT,
2424 success_Steal INT,
2425 street1Seen INT,
2426 street2Seen INT,
2427 street3Seen INT,
2428 street4Seen INT,
2429 sawShowdown INT,
2430 street1Aggr INT,
2431 street2Aggr INT,
2432 street3Aggr INT,
2433 street4Aggr INT,
2434 otherRaisedStreet0 INT,
2435 otherRaisedStreet1 INT,
2436 otherRaisedStreet2 INT,
2437 otherRaisedStreet3 INT,
2438 otherRaisedStreet4 INT,
2439 foldToOtherRaisedStreet0 INT,
2440 foldToOtherRaisedStreet1 INT,
2441 foldToOtherRaisedStreet2 INT,
2442 foldToOtherRaisedStreet3 INT,
2443 foldToOtherRaisedStreet4 INT,
2444 wonWhenSeenStreet1 INT,
2445 wonWhenSeenStreet2 INT,
2446 wonWhenSeenStreet3 INT,
2447 wonWhenSeenStreet4 INT,
2448 wonAtSD INT,
2449 raiseFirstInChance INT,
2450 raisedFirstIn INT,
2451 foldBbToStealChance INT,
2452 foldedBbToSteal INT,
2453 foldSbToStealChance INT,
2454 foldedSbToSteal INT,
2455 street1CBChance INT,
2456 street1CBDone INT,
2457 street2CBChance INT,
2458 street2CBDone INT,
2459 street3CBChance INT,
2460 street3CBDone INT,
2461 street4CBChance INT,
2462 street4CBDone INT,
2463 foldToStreet1CBChance INT,
2464 foldToStreet1CBDone INT,
2465 foldToStreet2CBChance INT,
2466 foldToStreet2CBDone INT,
2467 foldToStreet3CBChance INT,
2468 foldToStreet3CBDone INT,
2469 foldToStreet4CBChance INT,
2470 foldToStreet4CBDone INT,
2471 common BIGINT,
2472 committed BIGINT,
2473 winnings BIGINT,
2474 rake BIGINT,
2475 rakeDealt NUMERIC,
2476 rakeContributed NUMERIC,
2477 rakeWeighted NUMERIC,
2478 totalProfit BIGINT,
2479 allInEV NUMERIC,
2480 showdownWinnings BIGINT,
2481 nonShowdownWinnings BIGINT,
2482 street1CheckCallRaiseChance INT,
2483 street1CheckCallDone INT,
2484 street1CheckRaiseDone INT,
2485 street2CheckCallRaiseChance INT,
2486 street2CheckCallDone INT,
2487 street2CheckRaiseDone INT,
2488 street3CheckCallRaiseChance INT,
2489 street3CheckCallDone INT,
2490 street3CheckRaiseDone INT,
2491 street4CheckCallRaiseChance INT,
2492 street4CheckCallDone INT,
2493 street4CheckRaiseDone INT,
2494 street0Calls INT,
2495 street1Calls INT,
2496 street2Calls INT,
2497 street3Calls INT,
2498 street4Calls INT,
2499 street0Bets INT,
2500 street1Bets INT,
2501 street2Bets INT,
2502 street3Bets INT,
2503 street4Bets INT,
2504 street0Raises INT,
2505 street1Raises INT,
2506 street2Raises INT,
2507 street3Raises INT,
2508 street4Raises INT,
2509 street1Discards INT,
2510 street2Discards INT,
2511 street3Discards INT)
2512 ENGINE=INNODB"""
2513 elif db_server == 'postgresql':
2514 self.query['createPositionsCacheTable'] = """CREATE TABLE PositionsCache (
2515 id BIGSERIAL, PRIMARY KEY (id),
2516 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2517 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id),
2518 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2519 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
2520 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
2521 seats SMALLINT,
2522 maxPosition SMALLINT NOT NULL,
2523 position CHAR(1),
2524 n INT,
2525 street0VPIChance INT,
2526 street0VPI INT,
2527 street0AggrChance INT,
2528 street0Aggr INT,
2529 street0CalledRaiseChance INT,
2530 street0CalledRaiseDone INT,
2531 street0_2BChance INT,
2532 street0_2BDone INT,
2533 street0_3BChance INT,
2534 street0_3BDone INT,
2535 street0_4BChance INT,
2536 street0_4BDone INT,
2537 street0_C4BChance INT,
2538 street0_C4BDone INT,
2539 street0_FoldTo2BChance INT,
2540 street0_FoldTo2BDone INT,
2541 street0_FoldTo3BChance INT,
2542 street0_FoldTo3BDone INT,
2543 street0_FoldTo4BChance INT,
2544 street0_FoldTo4BDone INT,
2545 street0_SqueezeChance INT,
2546 street0_SqueezeDone INT,
2547 raiseToStealChance INT,
2548 raiseToStealDone INT,
2549 stealChance INT,
2550 stealDone INT,
2551 success_Steal INT,
2552 street1Seen INT,
2553 street2Seen INT,
2554 street3Seen INT,
2555 street4Seen INT,
2556 sawShowdown INT,
2557 street1Aggr INT,
2558 street2Aggr INT,
2559 street3Aggr INT,
2560 street4Aggr INT,
2561 otherRaisedStreet0 INT,
2562 otherRaisedStreet1 INT,
2563 otherRaisedStreet2 INT,
2564 otherRaisedStreet3 INT,
2565 otherRaisedStreet4 INT,
2566 foldToOtherRaisedStreet0 INT,
2567 foldToOtherRaisedStreet1 INT,
2568 foldToOtherRaisedStreet2 INT,
2569 foldToOtherRaisedStreet3 INT,
2570 foldToOtherRaisedStreet4 INT,
2571 wonWhenSeenStreet1 INT,
2572 wonWhenSeenStreet2 INT,
2573 wonWhenSeenStreet3 INT,
2574 wonWhenSeenStreet4 INT,
2575 wonAtSD INT,
2576 raiseFirstInChance INT,
2577 raisedFirstIn INT,
2578 foldBbToStealChance INT,
2579 foldedBbToSteal INT,
2580 foldSbToStealChance INT,
2581 foldedSbToSteal INT,
2582 street1CBChance INT,
2583 street1CBDone INT,
2584 street2CBChance INT,
2585 street2CBDone INT,
2586 street3CBChance INT,
2587 street3CBDone INT,
2588 street4CBChance INT,
2589 street4CBDone INT,
2590 foldToStreet1CBChance INT,
2591 foldToStreet1CBDone INT,
2592 foldToStreet2CBChance INT,
2593 foldToStreet2CBDone INT,
2594 foldToStreet3CBChance INT,
2595 foldToStreet3CBDone INT,
2596 foldToStreet4CBChance INT,
2597 foldToStreet4CBDone INT,
2598 common BIGINT,
2599 committed BIGINT,
2600 winnings BIGINT,
2601 rake BIGINT,
2602 rakeDealt NUMERIC,
2603 rakeContributed NUMERIC,
2604 rakeWeighted NUMERIC,
2605 totalProfit BIGINT,
2606 allInEV NUMERIC,
2607 showdownWinnings BIGINT,
2608 nonShowdownWinnings BIGINT,
2609 street1CheckCallRaiseChance INT,
2610 street1CheckCallDone INT,
2611 street1CheckRaiseDone INT,
2612 street2CheckCallRaiseChance INT,
2613 street2CheckCallDone INT,
2614 street2CheckRaiseDone INT,
2615 street3CheckCallRaiseChance INT,
2616 street3CheckCallDone INT,
2617 street3CheckRaiseDone INT,
2618 street4CheckCallRaiseChance INT,
2619 street4CheckCallDone INT,
2620 street4CheckRaiseDone INT,
2621 street0Calls INT,
2622 street1Calls INT,
2623 street2Calls INT,
2624 street3Calls INT,
2625 street4Calls INT,
2626 street0Bets INT,
2627 street1Bets INT,
2628 street2Bets INT,
2629 street3Bets INT,
2630 street4Bets INT,
2631 street0Raises INT,
2632 street1Raises INT,
2633 street2Raises INT,
2634 street3Raises INT,
2635 street4Raises INT,
2636 street1Discards INT,
2637 street2Discards INT,
2638 street3Discards INT)
2639 """
2640 elif db_server == 'sqlite':
2641 self.query['createPositionsCacheTable'] = """CREATE TABLE PositionsCache (
2642 id INTEGER PRIMARY KEY,
2643 weekId INT,
2644 monthId INT,
2645 gametypeId INT,
2646 tourneyTypeId INT,
2647 playerId INT,
2648 seats INT,
2649 maxPosition INT NOT NULL,
2650 position TEXT,
2651 n INT,
2652 street0VPIChance INT,
2653 street0VPI INT,
2654 street0AggrChance INT,
2655 street0Aggr INT,
2656 street0CalledRaiseChance INT,
2657 street0CalledRaiseDone INT,
2658 street0_2BChance INT,
2659 street0_2BDone INT,
2660 street0_3BChance INT,
2661 street0_3BDone INT,
2662 street0_4BChance INT,
2663 street0_4BDone INT,
2664 street0_C4BChance INT,
2665 street0_C4BDone INT,
2666 street0_FoldTo2BChance INT,
2667 street0_FoldTo2BDone INT,
2668 street0_FoldTo3BChance INT,
2669 street0_FoldTo3BDone INT,
2670 street0_FoldTo4BChance INT,
2671 street0_FoldTo4BDone INT,
2672 street0_SqueezeChance INT,
2673 street0_SqueezeDone INT,
2674 raiseToStealChance INT,
2675 raiseToStealDone INT,
2676 stealChance INT,
2677 stealDone INT,
2678 success_Steal INT,
2679 street1Seen INT,
2680 street2Seen INT,
2681 street3Seen INT,
2682 street4Seen INT,
2683 sawShowdown INT,
2684 street1Aggr INT,
2685 street2Aggr INT,
2686 street3Aggr INT,
2687 street4Aggr INT,
2688 otherRaisedStreet0 INT,
2689 otherRaisedStreet1 INT,
2690 otherRaisedStreet2 INT,
2691 otherRaisedStreet3 INT,
2692 otherRaisedStreet4 INT,
2693 foldToOtherRaisedStreet0 INT,
2694 foldToOtherRaisedStreet1 INT,
2695 foldToOtherRaisedStreet2 INT,
2696 foldToOtherRaisedStreet3 INT,
2697 foldToOtherRaisedStreet4 INT,
2698 wonWhenSeenStreet1 INT,
2699 wonWhenSeenStreet2 INT,
2700 wonWhenSeenStreet3 INT,
2701 wonWhenSeenStreet4 INT,
2702 wonAtSD INT,
2703 raiseFirstInChance INT,
2704 raisedFirstIn INT,
2705 foldBbToStealChance INT,
2706 foldedBbToSteal INT,
2707 foldSbToStealChance INT,
2708 foldedSbToSteal INT,
2709 street1CBChance INT,
2710 street1CBDone INT,
2711 street2CBChance INT,
2712 street2CBDone INT,
2713 street3CBChance INT,
2714 street3CBDone INT,
2715 street4CBChance INT,
2716 street4CBDone INT,
2717 foldToStreet1CBChance INT,
2718 foldToStreet1CBDone INT,
2719 foldToStreet2CBChance INT,
2720 foldToStreet2CBDone INT,
2721 foldToStreet3CBChance INT,
2722 foldToStreet3CBDone INT,
2723 foldToStreet4CBChance INT,
2724 foldToStreet4CBDone INT,
2725 common INT,
2726 committed INT,
2727 winnings INT,
2728 rake INT,
2729 rakeDealt decimal,
2730 rakeContributed decimal,
2731 rakeWeighted decimal,
2732 totalProfit INT,
2733 allInEV decimal,
2734 showdownWinnings INT,
2735 nonShowdownWinnings INT,
2736 street1CheckCallRaiseChance INT,
2737 street1CheckCallDone INT,
2738 street1CheckRaiseDone INT,
2739 street2CheckCallRaiseChance INT,
2740 street2CheckCallDone INT,
2741 street2CheckRaiseDone INT,
2742 street3CheckCallRaiseChance INT,
2743 street3CheckCallDone INT,
2744 street3CheckRaiseDone INT,
2745 street4CheckCallRaiseChance INT,
2746 street4CheckCallDone INT,
2747 street4CheckRaiseDone INT,
2748 street0Calls INT,
2749 street1Calls INT,
2750 street2Calls INT,
2751 street3Calls INT,
2752 street4Calls INT,
2753 street0Bets INT,
2754 street1Bets INT,
2755 street2Bets INT,
2756 street3Bets INT,
2757 street4Bets INT,
2758 street0Raises INT,
2759 street1Raises INT,
2760 street2Raises INT,
2761 street3Raises INT,
2762 street4Raises INT,
2763 street1Discards INT,
2764 street2Discards INT,
2765 street3Discards INT)
2766 """
2768 ################################
2769 # Create Weeks
2770 ################################
2772 if db_server == 'mysql':
2773 self.query['createWeeksTable'] = """CREATE TABLE Weeks (
2774 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2775 weekStart DATETIME NOT NULL)
2776 ENGINE=INNODB
2777 """
2779 elif db_server == 'postgresql':
2780 self.query['createWeeksTable'] = """CREATE TABLE Weeks (
2781 id SERIAL, PRIMARY KEY (id),
2782 weekStart timestamp without time zone NOT NULL)
2783 """
2785 elif db_server == 'sqlite':
2786 self.query['createWeeksTable'] = """CREATE TABLE Weeks (
2787 id INTEGER PRIMARY KEY,
2788 weekStart timestamp NOT NULL)
2789 """
2791 ################################
2792 # Create Months
2793 ################################
2795 if db_server == 'mysql':
2796 self.query['createMonthsTable'] = """CREATE TABLE Months (
2797 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2798 monthStart DATETIME NOT NULL)
2799 ENGINE=INNODB
2800 """
2802 elif db_server == 'postgresql':
2803 self.query['createMonthsTable'] = """CREATE TABLE Months (
2804 id SERIAL, PRIMARY KEY (id),
2805 monthStart timestamp without time zone NOT NULL)
2806 """
2808 elif db_server == 'sqlite':
2809 self.query['createMonthsTable'] = """CREATE TABLE Months (
2810 id INTEGER PRIMARY KEY,
2811 monthStart timestamp NOT NULL)
2812 """
2814 ################################
2815 # Create Sessions
2816 ################################
2818 if db_server == 'mysql':
2819 self.query['createSessionsTable'] = """CREATE TABLE Sessions (
2820 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2821 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2822 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id),
2823 sessionStart DATETIME NOT NULL,
2824 sessionEnd DATETIME NOT NULL)
2825 ENGINE=INNODB
2826 """
2828 elif db_server == 'postgresql':
2829 self.query['createSessionsTable'] = """CREATE TABLE Sessions (
2830 id SERIAL, PRIMARY KEY (id),
2831 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id),
2832 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id),
2833 sessionStart timestamp without time zone NOT NULL,
2834 sessionEnd timestamp without time zone NOT NULL)
2835 """
2837 elif db_server == 'sqlite':
2838 self.query['createSessionsTable'] = """CREATE TABLE Sessions (
2839 id INTEGER PRIMARY KEY,
2840 weekId INT,
2841 monthId INT,
2842 sessionStart timestamp NOT NULL,
2843 sessionEnd timestamp NOT NULL)
2844 """
2846 ################################
2847 # Create SessionsCache
2848 ################################
2850 if db_server == 'mysql':
2851 self.query['createSessionsCacheTable'] = """CREATE TABLE SessionsCache (
2852 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
2853 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
2854 startTime DATETIME NOT NULL,
2855 endTime DATETIME NOT NULL,
2856 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2857 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
2858 n INT NOT NULL,
2859 street0VPIChance INT,
2860 street0VPI INT,
2861 street0AggrChance INT,
2862 street0Aggr INT,
2863 street0CalledRaiseChance INT,
2864 street0CalledRaiseDone INT,
2865 street0_2BChance INT,
2866 street0_2BDone INT,
2867 street0_3BChance INT,
2868 street0_3BDone INT,
2869 street0_4BChance INT,
2870 street0_4BDone INT,
2871 street0_C4BChance INT,
2872 street0_C4BDone INT,
2873 street0_FoldTo2BChance INT,
2874 street0_FoldTo2BDone INT,
2875 street0_FoldTo3BChance INT,
2876 street0_FoldTo3BDone INT,
2877 street0_FoldTo4BChance INT,
2878 street0_FoldTo4BDone INT,
2879 street0_SqueezeChance INT,
2880 street0_SqueezeDone INT,
2881 raiseToStealChance INT,
2882 raiseToStealDone INT,
2883 stealChance INT,
2884 stealDone INT,
2885 success_Steal INT,
2886 street1Seen INT,
2887 street2Seen INT,
2888 street3Seen INT,
2889 street4Seen INT,
2890 sawShowdown INT,
2891 street1Aggr INT,
2892 street2Aggr INT,
2893 street3Aggr INT,
2894 street4Aggr INT,
2895 otherRaisedStreet0 INT,
2896 otherRaisedStreet1 INT,
2897 otherRaisedStreet2 INT,
2898 otherRaisedStreet3 INT,
2899 otherRaisedStreet4 INT,
2900 foldToOtherRaisedStreet0 INT,
2901 foldToOtherRaisedStreet1 INT,
2902 foldToOtherRaisedStreet2 INT,
2903 foldToOtherRaisedStreet3 INT,
2904 foldToOtherRaisedStreet4 INT,
2905 wonWhenSeenStreet1 INT,
2906 wonWhenSeenStreet2 INT,
2907 wonWhenSeenStreet3 INT,
2908 wonWhenSeenStreet4 INT,
2909 wonAtSD INT,
2910 raiseFirstInChance INT,
2911 raisedFirstIn INT,
2912 foldBbToStealChance INT,
2913 foldedBbToSteal INT,
2914 foldSbToStealChance INT,
2915 foldedSbToSteal INT,
2916 street1CBChance INT,
2917 street1CBDone INT,
2918 street2CBChance INT,
2919 street2CBDone INT,
2920 street3CBChance INT,
2921 street3CBDone INT,
2922 street4CBChance INT,
2923 street4CBDone INT,
2924 foldToStreet1CBChance INT,
2925 foldToStreet1CBDone INT,
2926 foldToStreet2CBChance INT,
2927 foldToStreet2CBDone INT,
2928 foldToStreet3CBChance INT,
2929 foldToStreet3CBDone INT,
2930 foldToStreet4CBChance INT,
2931 foldToStreet4CBDone INT,
2932 common BIGINT,
2933 committed BIGINT,
2934 winnings BIGINT,
2935 rake BIGINT,
2936 rakeDealt NUMERIC,
2937 rakeContributed NUMERIC,
2938 rakeWeighted NUMERIC,
2939 totalProfit BIGINT,
2940 allInEV NUMERIC,
2941 showdownWinnings BIGINT,
2942 nonShowdownWinnings BIGINT,
2943 street1CheckCallRaiseChance INT,
2944 street1CheckCallDone INT,
2945 street1CheckRaiseDone INT,
2946 street2CheckCallRaiseChance INT,
2947 street2CheckCallDone INT,
2948 street2CheckRaiseDone INT,
2949 street3CheckCallRaiseChance INT,
2950 street3CheckCallDone INT,
2951 street3CheckRaiseDone INT,
2952 street4CheckCallRaiseChance INT,
2953 street4CheckCallDone INT,
2954 street4CheckRaiseDone INT,
2955 street0Calls INT,
2956 street1Calls INT,
2957 street2Calls INT,
2958 street3Calls INT,
2959 street4Calls INT,
2960 street0Bets INT,
2961 street1Bets INT,
2962 street2Bets INT,
2963 street3Bets INT,
2964 street4Bets INT,
2965 street0Raises INT,
2966 street1Raises INT,
2967 street2Raises INT,
2968 street3Raises INT,
2969 street4Raises INT,
2970 street1Discards INT,
2971 street2Discards INT,
2972 street3Discards INT)
2973 ENGINE=INNODB
2974 """
2976 elif db_server == 'postgresql':
2977 self.query['createSessionsCacheTable'] = """CREATE TABLE SessionsCache (
2978 id SERIAL, PRIMARY KEY (id),
2979 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
2980 startTime timestamp without time zone NOT NULL,
2981 endTime timestamp without time zone NOT NULL,
2982 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
2983 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
2984 n INT,
2985 street0VPIChance INT,
2986 street0VPI INT,
2987 street0AggrChance INT,
2988 street0Aggr INT,
2989 street0CalledRaiseChance INT,
2990 street0CalledRaiseDone INT,
2991 street0_2BChance INT,
2992 street0_2BDone INT,
2993 street0_3BChance INT,
2994 street0_3BDone INT,
2995 street0_4BChance INT,
2996 street0_4BDone INT,
2997 street0_C4BChance INT,
2998 street0_C4BDone INT,
2999 street0_FoldTo2BChance INT,
3000 street0_FoldTo2BDone INT,
3001 street0_FoldTo3BChance INT,
3002 street0_FoldTo3BDone INT,
3003 street0_FoldTo4BChance INT,
3004 street0_FoldTo4BDone INT,
3005 street0_SqueezeChance INT,
3006 street0_SqueezeDone INT,
3007 raiseToStealChance INT,
3008 raiseToStealDone INT,
3009 stealChance INT,
3010 stealDone INT,
3011 success_Steal INT,
3012 street1Seen INT,
3013 street2Seen INT,
3014 street3Seen INT,
3015 street4Seen INT,
3016 sawShowdown INT,
3017 street1Aggr INT,
3018 street2Aggr INT,
3019 street3Aggr INT,
3020 street4Aggr INT,
3021 otherRaisedStreet0 INT,
3022 otherRaisedStreet1 INT,
3023 otherRaisedStreet2 INT,
3024 otherRaisedStreet3 INT,
3025 otherRaisedStreet4 INT,
3026 foldToOtherRaisedStreet0 INT,
3027 foldToOtherRaisedStreet1 INT,
3028 foldToOtherRaisedStreet2 INT,
3029 foldToOtherRaisedStreet3 INT,
3030 foldToOtherRaisedStreet4 INT,
3031 wonWhenSeenStreet1 INT,
3032 wonWhenSeenStreet2 INT,
3033 wonWhenSeenStreet3 INT,
3034 wonWhenSeenStreet4 INT,
3035 wonAtSD INT,
3036 raiseFirstInChance INT,
3037 raisedFirstIn INT,
3038 foldBbToStealChance INT,
3039 foldedBbToSteal INT,
3040 foldSbToStealChance INT,
3041 foldedSbToSteal INT,
3042 street1CBChance INT,
3043 street1CBDone INT,
3044 street2CBChance INT,
3045 street2CBDone INT,
3046 street3CBChance INT,
3047 street3CBDone INT,
3048 street4CBChance INT,
3049 street4CBDone INT,
3050 foldToStreet1CBChance INT,
3051 foldToStreet1CBDone INT,
3052 foldToStreet2CBChance INT,
3053 foldToStreet2CBDone INT,
3054 foldToStreet3CBChance INT,
3055 foldToStreet3CBDone INT,
3056 foldToStreet4CBChance INT,
3057 foldToStreet4CBDone INT,
3058 common BIGINT,
3059 committed BIGINT,
3060 winnings BIGINT,
3061 rake BIGINT,
3062 rakeDealt NUMERIC,
3063 rakeContributed NUMERIC,
3064 rakeWeighted NUMERIC,
3065 totalProfit BIGINT,
3066 allInEV NUMERIC,
3067 showdownWinnings BIGINT,
3068 nonShowdownWinnings BIGINT,
3069 street1CheckCallRaiseChance INT,
3070 street1CheckCallDone INT,
3071 street1CheckRaiseDone INT,
3072 street2CheckCallRaiseChance INT,
3073 street2CheckCallDone INT,
3074 street2CheckRaiseDone INT,
3075 street3CheckCallRaiseChance INT,
3076 street3CheckCallDone INT,
3077 street3CheckRaiseDone INT,
3078 street4CheckCallRaiseChance INT,
3079 street4CheckCallDone INT,
3080 street4CheckRaiseDone INT,
3081 street0Calls INT,
3082 street1Calls INT,
3083 street2Calls INT,
3084 street3Calls INT,
3085 street4Calls INT,
3086 street0Bets INT,
3087 street1Bets INT,
3088 street2Bets INT,
3089 street3Bets INT,
3090 street4Bets INT,
3091 street0Raises INT,
3092 street1Raises INT,
3093 street2Raises INT,
3094 street3Raises INT,
3095 street4Raises INT,
3096 street1Discards INT,
3097 street2Discards INT,
3098 street3Discards INT)
3099 """
3101 elif db_server == 'sqlite':
3102 self.query['createSessionsCacheTable'] = """CREATE TABLE SessionsCache (
3103 id INTEGER PRIMARY KEY,
3104 sessionId INT,
3105 startTime timestamp NOT NULL,
3106 endTime timestamp NOT NULL,
3107 gametypeId INT,
3108 playerId INT,
3109 n INT,
3110 street0VPIChance INT,
3111 street0VPI INT,
3112 street0AggrChance INT,
3113 street0Aggr INT,
3114 street0CalledRaiseChance INT,
3115 street0CalledRaiseDone INT,
3116 street0_2BChance INT,
3117 street0_2BDone INT,
3118 street0_3BChance INT,
3119 street0_3BDone INT,
3120 street0_4BChance INT,
3121 street0_4BDone INT,
3122 street0_C4BChance INT,
3123 street0_C4BDone INT,
3124 street0_FoldTo2BChance INT,
3125 street0_FoldTo2BDone INT,
3126 street0_FoldTo3BChance INT,
3127 street0_FoldTo3BDone INT,
3128 street0_FoldTo4BChance INT,
3129 street0_FoldTo4BDone INT,
3130 street0_SqueezeChance INT,
3131 street0_SqueezeDone INT,
3132 raiseToStealChance INT,
3133 raiseToStealDone INT,
3134 stealChance INT,
3135 stealDone INT,
3136 success_Steal INT,
3137 street1Seen INT,
3138 street2Seen INT,
3139 street3Seen INT,
3140 street4Seen INT,
3141 sawShowdown INT,
3142 street1Aggr INT,
3143 street2Aggr INT,
3144 street3Aggr INT,
3145 street4Aggr INT,
3146 otherRaisedStreet0 INT,
3147 otherRaisedStreet1 INT,
3148 otherRaisedStreet2 INT,
3149 otherRaisedStreet3 INT,
3150 otherRaisedStreet4 INT,
3151 foldToOtherRaisedStreet0 INT,
3152 foldToOtherRaisedStreet1 INT,
3153 foldToOtherRaisedStreet2 INT,
3154 foldToOtherRaisedStreet3 INT,
3155 foldToOtherRaisedStreet4 INT,
3156 wonWhenSeenStreet1 INT,
3157 wonWhenSeenStreet2 INT,
3158 wonWhenSeenStreet3 INT,
3159 wonWhenSeenStreet4 INT,
3160 wonAtSD INT,
3161 raiseFirstInChance INT,
3162 raisedFirstIn INT,
3163 foldBbToStealChance INT,
3164 foldedBbToSteal INT,
3165 foldSbToStealChance INT,
3166 foldedSbToSteal INT,
3167 street1CBChance INT,
3168 street1CBDone INT,
3169 street2CBChance INT,
3170 street2CBDone INT,
3171 street3CBChance INT,
3172 street3CBDone INT,
3173 street4CBChance INT,
3174 street4CBDone INT,
3175 foldToStreet1CBChance INT,
3176 foldToStreet1CBDone INT,
3177 foldToStreet2CBChance INT,
3178 foldToStreet2CBDone INT,
3179 foldToStreet3CBChance INT,
3180 foldToStreet3CBDone INT,
3181 foldToStreet4CBChance INT,
3182 foldToStreet4CBDone INT,
3183 common INT,
3184 committed INT,
3185 winnings INT,
3186 rake INT,
3187 rakeDealt decimal,
3188 rakeContributed decimal,
3189 rakeWeighted decimal,
3190 totalProfit INT,
3191 allInEV decimal,
3192 showdownWinnings INT,
3193 nonShowdownWinnings INT,
3194 street1CheckCallRaiseChance INT,
3195 street1CheckCallDone INT,
3196 street1CheckRaiseDone INT,
3197 street2CheckCallRaiseChance INT,
3198 street2CheckCallDone INT,
3199 street2CheckRaiseDone INT,
3200 street3CheckCallRaiseChance INT,
3201 street3CheckCallDone INT,
3202 street3CheckRaiseDone INT,
3203 street4CheckCallRaiseChance INT,
3204 street4CheckCallDone INT,
3205 street4CheckRaiseDone INT,
3206 street0Calls INT,
3207 street1Calls INT,
3208 street2Calls INT,
3209 street3Calls INT,
3210 street4Calls INT,
3211 street0Bets INT,
3212 street1Bets INT,
3213 street2Bets INT,
3214 street3Bets INT,
3215 street4Bets INT,
3216 street0Raises INT,
3217 street1Raises INT,
3218 street2Raises INT,
3219 street3Raises INT,
3220 street4Raises INT,
3221 street1Discards INT,
3222 street2Discards INT,
3223 street3Discards INT)
3224 """
3226 ################################
3227 # Create TourneysCache
3228 ################################
3230 if db_server == 'mysql':
3231 self.query['createTourneysCacheTable'] = """CREATE TABLE TourneysCache (
3232 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
3233 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
3234 startTime DATETIME NOT NULL,
3235 endTime DATETIME NOT NULL,
3236 tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
3237 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
3238 n INT NOT NULL,
3239 street0VPIChance INT,
3240 street0VPI INT,
3241 street0AggrChance INT,
3242 street0Aggr INT,
3243 street0CalledRaiseChance INT,
3244 street0CalledRaiseDone INT,
3245 street0_2BChance INT,
3246 street0_2BDone INT,
3247 street0_3BChance INT,
3248 street0_3BDone INT,
3249 street0_4BChance INT,
3250 street0_4BDone INT,
3251 street0_C4BChance INT,
3252 street0_C4BDone INT,
3253 street0_FoldTo2BChance INT,
3254 street0_FoldTo2BDone INT,
3255 street0_FoldTo3BChance INT,
3256 street0_FoldTo3BDone INT,
3257 street0_FoldTo4BChance INT,
3258 street0_FoldTo4BDone INT,
3259 street0_SqueezeChance INT,
3260 street0_SqueezeDone INT,
3261 raiseToStealChance INT,
3262 raiseToStealDone INT,
3263 stealChance INT,
3264 stealDone INT,
3265 success_Steal INT,
3266 street1Seen INT,
3267 street2Seen INT,
3268 street3Seen INT,
3269 street4Seen INT,
3270 sawShowdown INT,
3271 street1Aggr INT,
3272 street2Aggr INT,
3273 street3Aggr INT,
3274 street4Aggr INT,
3275 otherRaisedStreet0 INT,
3276 otherRaisedStreet1 INT,
3277 otherRaisedStreet2 INT,
3278 otherRaisedStreet3 INT,
3279 otherRaisedStreet4 INT,
3280 foldToOtherRaisedStreet0 INT,
3281 foldToOtherRaisedStreet1 INT,
3282 foldToOtherRaisedStreet2 INT,
3283 foldToOtherRaisedStreet3 INT,
3284 foldToOtherRaisedStreet4 INT,
3285 wonWhenSeenStreet1 INT,
3286 wonWhenSeenStreet2 INT,
3287 wonWhenSeenStreet3 INT,
3288 wonWhenSeenStreet4 INT,
3289 wonAtSD INT,
3290 raiseFirstInChance INT,
3291 raisedFirstIn INT,
3292 foldBbToStealChance INT,
3293 foldedBbToSteal INT,
3294 foldSbToStealChance INT,
3295 foldedSbToSteal INT,
3296 street1CBChance INT,
3297 street1CBDone INT,
3298 street2CBChance INT,
3299 street2CBDone INT,
3300 street3CBChance INT,
3301 street3CBDone INT,
3302 street4CBChance INT,
3303 street4CBDone INT,
3304 foldToStreet1CBChance INT,
3305 foldToStreet1CBDone INT,
3306 foldToStreet2CBChance INT,
3307 foldToStreet2CBDone INT,
3308 foldToStreet3CBChance INT,
3309 foldToStreet3CBDone INT,
3310 foldToStreet4CBChance INT,
3311 foldToStreet4CBDone INT,
3312 common BIGINT,
3313 committed BIGINT,
3314 winnings BIGINT,
3315 rake BIGINT,
3316 rakeDealt NUMERIC,
3317 rakeContributed NUMERIC,
3318 rakeWeighted NUMERIC,
3319 totalProfit BIGINT,
3320 allInEV NUMERIC,
3321 showdownWinnings BIGINT,
3322 nonShowdownWinnings BIGINT,
3323 street1CheckCallRaiseChance INT,
3324 street1CheckCallDone INT,
3325 street1CheckRaiseDone INT,
3326 street2CheckCallRaiseChance INT,
3327 street2CheckCallDone INT,
3328 street2CheckRaiseDone INT,
3329 street3CheckCallRaiseChance INT,
3330 street3CheckCallDone INT,
3331 street3CheckRaiseDone INT,
3332 street4CheckCallRaiseChance INT,
3333 street4CheckCallDone INT,
3334 street4CheckRaiseDone INT,
3335 street0Calls INT,
3336 street1Calls INT,
3337 street2Calls INT,
3338 street3Calls INT,
3339 street4Calls INT,
3340 street0Bets INT,
3341 street1Bets INT,
3342 street2Bets INT,
3343 street3Bets INT,
3344 street4Bets INT,
3345 street0Raises INT,
3346 street1Raises INT,
3347 street2Raises INT,
3348 street3Raises INT,
3349 street4Raises INT,
3350 street1Discards INT,
3351 street2Discards INT,
3352 street3Discards INT)
3353 ENGINE=INNODB
3354 """
3356 elif db_server == 'postgresql':
3357 self.query['createTourneysCacheTable'] = """CREATE TABLE TourneysCache (
3358 id SERIAL, PRIMARY KEY (id),
3359 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id),
3360 startTime timestamp without time zone NOT NULL,
3361 endTime timestamp without time zone NOT NULL,
3362 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
3363 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
3364 n INT,
3365 street0VPIChance INT,
3366 street0VPI INT,
3367 street0AggrChance INT,
3368 street0Aggr INT,
3369 street0CalledRaiseChance INT,
3370 street0CalledRaiseDone INT,
3371 street0_2BChance INT,
3372 street0_2BDone INT,
3373 street0_3BChance INT,
3374 street0_3BDone INT,
3375 street0_4BChance INT,
3376 street0_4BDone INT,
3377 street0_C4BChance INT,
3378 street0_C4BDone INT,
3379 street0_FoldTo2BChance INT,
3380 street0_FoldTo2BDone INT,
3381 street0_FoldTo3BChance INT,
3382 street0_FoldTo3BDone INT,
3383 street0_FoldTo4BChance INT,
3384 street0_FoldTo4BDone INT,
3385 street0_SqueezeChance INT,
3386 street0_SqueezeDone INT,
3387 raiseToStealChance INT,
3388 raiseToStealDone INT,
3389 stealChance INT,
3390 stealDone INT,
3391 success_Steal INT,
3392 street1Seen INT,
3393 street2Seen INT,
3394 street3Seen INT,
3395 street4Seen INT,
3396 sawShowdown INT,
3397 street1Aggr INT,
3398 street2Aggr INT,
3399 street3Aggr INT,
3400 street4Aggr INT,
3401 otherRaisedStreet0 INT,
3402 otherRaisedStreet1 INT,
3403 otherRaisedStreet2 INT,
3404 otherRaisedStreet3 INT,
3405 otherRaisedStreet4 INT,
3406 foldToOtherRaisedStreet0 INT,
3407 foldToOtherRaisedStreet1 INT,
3408 foldToOtherRaisedStreet2 INT,
3409 foldToOtherRaisedStreet3 INT,
3410 foldToOtherRaisedStreet4 INT,
3411 wonWhenSeenStreet1 INT,
3412 wonWhenSeenStreet2 INT,
3413 wonWhenSeenStreet3 INT,
3414 wonWhenSeenStreet4 INT,
3415 wonAtSD INT,
3416 raiseFirstInChance INT,
3417 raisedFirstIn INT,
3418 foldBbToStealChance INT,
3419 foldedBbToSteal INT,
3420 foldSbToStealChance INT,
3421 foldedSbToSteal INT,
3422 street1CBChance INT,
3423 street1CBDone INT,
3424 street2CBChance INT,
3425 street2CBDone INT,
3426 street3CBChance INT,
3427 street3CBDone INT,
3428 street4CBChance INT,
3429 street4CBDone INT,
3430 foldToStreet1CBChance INT,
3431 foldToStreet1CBDone INT,
3432 foldToStreet2CBChance INT,
3433 foldToStreet2CBDone INT,
3434 foldToStreet3CBChance INT,
3435 foldToStreet3CBDone INT,
3436 foldToStreet4CBChance INT,
3437 foldToStreet4CBDone INT,
3438 common BIGINT,
3439 committed BIGINT,
3440 winnings BIGINT,
3441 rake BIGINT,
3442 rakeDealt NUMERIC,
3443 rakeContributed NUMERIC,
3444 rakeWeighted NUMERIC,
3445 totalProfit BIGINT,
3446 allInEV NUMERIC,
3447 showdownWinnings BIGINT,
3448 nonShowdownWinnings BIGINT,
3449 street1CheckCallRaiseChance INT,
3450 street1CheckCallDone INT,
3451 street1CheckRaiseDone INT,
3452 street2CheckCallRaiseChance INT,
3453 street2CheckCallDone INT,
3454 street2CheckRaiseDone INT,
3455 street3CheckCallRaiseChance INT,
3456 street3CheckCallDone INT,
3457 street3CheckRaiseDone INT,
3458 street4CheckCallRaiseChance INT,
3459 street4CheckCallDone INT,
3460 street4CheckRaiseDone INT,
3461 street0Calls INT,
3462 street1Calls INT,
3463 street2Calls INT,
3464 street3Calls INT,
3465 street4Calls INT,
3466 street0Bets INT,
3467 street1Bets INT,
3468 street2Bets INT,
3469 street3Bets INT,
3470 street4Bets INT,
3471 street0Raises INT,
3472 street1Raises INT,
3473 street2Raises INT,
3474 street3Raises INT,
3475 street4Raises INT,
3476 street1Discards INT,
3477 street2Discards INT,
3478 street3Discards INT)
3479 """
3481 elif db_server == 'sqlite':
3482 self.query['createTourneysCacheTable'] = """CREATE TABLE TourneysCache (
3483 id INTEGER PRIMARY KEY,
3484 sessionId INT,
3485 startTime timestamp NOT NULL,
3486 endTime timestamp NOT NULL,
3487 tourneyId INT,
3488 playerId INT,
3489 n INT,
3490 street0VPIChance INT,
3491 street0VPI INT,
3492 street0AggrChance INT,
3493 street0Aggr INT,
3494 street0CalledRaiseChance INT,
3495 street0CalledRaiseDone INT,
3496 street0_2BChance INT,
3497 street0_2BDone INT,
3498 street0_3BChance INT,
3499 street0_3BDone INT,
3500 street0_4BChance INT,
3501 street0_4BDone INT,
3502 street0_C4BChance INT,
3503 street0_C4BDone INT,
3504 street0_FoldTo2BChance INT,
3505 street0_FoldTo2BDone INT,
3506 street0_FoldTo3BChance INT,
3507 street0_FoldTo3BDone INT,
3508 street0_FoldTo4BChance INT,
3509 street0_FoldTo4BDone INT,
3510 street0_SqueezeChance INT,
3511 street0_SqueezeDone INT,
3512 raiseToStealChance INT,
3513 raiseToStealDone INT,
3514 stealChance INT,
3515 stealDone INT,
3516 success_Steal INT,
3517 street1Seen INT,
3518 street2Seen INT,
3519 street3Seen INT,
3520 street4Seen INT,
3521 sawShowdown INT,
3522 street1Aggr INT,
3523 street2Aggr INT,
3524 street3Aggr INT,
3525 street4Aggr INT,
3526 otherRaisedStreet0 INT,
3527 otherRaisedStreet1 INT,
3528 otherRaisedStreet2 INT,
3529 otherRaisedStreet3 INT,
3530 otherRaisedStreet4 INT,
3531 foldToOtherRaisedStreet0 INT,
3532 foldToOtherRaisedStreet1 INT,
3533 foldToOtherRaisedStreet2 INT,
3534 foldToOtherRaisedStreet3 INT,
3535 foldToOtherRaisedStreet4 INT,
3536 wonWhenSeenStreet1 INT,
3537 wonWhenSeenStreet2 INT,
3538 wonWhenSeenStreet3 INT,
3539 wonWhenSeenStreet4 INT,
3540 wonAtSD INT,
3541 raiseFirstInChance INT,
3542 raisedFirstIn INT,
3543 foldBbToStealChance INT,
3544 foldedBbToSteal INT,
3545 foldSbToStealChance INT,
3546 foldedSbToSteal INT,
3547 street1CBChance INT,
3548 street1CBDone INT,
3549 street2CBChance INT,
3550 street2CBDone INT,
3551 street3CBChance INT,
3552 street3CBDone INT,
3553 street4CBChance INT,
3554 street4CBDone INT,
3555 foldToStreet1CBChance INT,
3556 foldToStreet1CBDone INT,
3557 foldToStreet2CBChance INT,
3558 foldToStreet2CBDone INT,
3559 foldToStreet3CBChance INT,
3560 foldToStreet3CBDone INT,
3561 foldToStreet4CBChance INT,
3562 foldToStreet4CBDone INT,
3563 common INT,
3564 committed INT,
3565 winnings INT,
3566 rake INT,
3567 rakeDealt decimal,
3568 rakeContributed decimal,
3569 rakeWeighted decimal,
3570 totalProfit INT,
3571 allInEV decimal,
3572 showdownWinnings INT,
3573 nonShowdownWinnings INT,
3574 street1CheckCallRaiseChance INT,
3575 street1CheckCallDone INT,
3576 street1CheckRaiseDone INT,
3577 street2CheckCallRaiseChance INT,
3578 street2CheckCallDone INT,
3579 street2CheckRaiseDone INT,
3580 street3CheckCallRaiseChance INT,
3581 street3CheckCallDone INT,
3582 street3CheckRaiseDone INT,
3583 street4CheckCallRaiseChance INT,
3584 street4CheckCallDone INT,
3585 street4CheckRaiseDone INT,
3586 street0Calls INT,
3587 street1Calls INT,
3588 street2Calls INT,
3589 street3Calls INT,
3590 street4Calls INT,
3591 street0Bets INT,
3592 street1Bets INT,
3593 street2Bets INT,
3594 street3Bets INT,
3595 street4Bets INT,
3596 street0Raises INT,
3597 street1Raises INT,
3598 street2Raises INT,
3599 street3Raises INT,
3600 street4Raises INT,
3601 street1Discards INT,
3602 street2Discards INT,
3603 street3Discards INT)
3604 """
3606 if db_server == 'mysql':
3607 self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD UNIQUE INDEX siteTourneyNo(siteTourneyNo, tourneyTypeId)"""
3608 elif db_server == 'postgresql':
3609 self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
3610 elif db_server == 'sqlite':
3611 self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)"""
3613 if db_server == 'mysql':
3614 self.query['addHandsIndex'] = """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gametypeId<heroseat>)"""
3615 elif db_server == 'postgresql':
3616 self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId<heroseat>)"""
3617 elif db_server == 'sqlite':
3618 self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId<heroseat>)"""
3620 if db_server == 'mysql':
3621 self.query['addPlayersSeat'] = """ALTER TABLE HandsPlayers ADD UNIQUE INDEX playerSeat_idx(handId, seatNo)"""
3622 elif db_server == 'postgresql':
3623 self.query['addPlayersSeat'] = """CREATE UNIQUE INDEX playerSeat_idx ON HandsPlayers (handId, seatNo)"""
3624 elif db_server == 'sqlite':
3625 self.query['addPlayersSeat'] = """CREATE UNIQUE INDEX playerSeat_idx ON HandsPlayers (handId, seatNo)"""
3627 if db_server == 'mysql':
3628 self.query['addHeroSeat'] = """ALTER TABLE Hands ADD UNIQUE INDEX heroSeat_idx(id, heroSeat)"""
3629 elif db_server == 'postgresql':
3630 self.query['addHeroSeat'] = """CREATE UNIQUE INDEX heroSeat_idx ON Hands (id, heroSeat)"""
3631 elif db_server == 'sqlite':
3632 self.query['addHeroSeat'] = """CREATE UNIQUE INDEX heroSeat_idx ON Hands (id, heroSeat)"""
3634 if db_server == 'mysql':
3635 self.query['addHandsPlayersSeat'] = """ALTER TABLE HandsPlayers ADD UNIQUE INDEX handsPlayerSeat_idx(handId, seatNo)"""
3636 elif db_server == 'postgresql':
3637 self.query['addHandsPlayersSeat'] = """CREATE UNIQUE INDEX handsPlayerSeat_idx ON Hands (handId, seatNo)"""
3638 elif db_server == 'sqlite':
3639 self.query['addHandsPlayersSeat'] = """CREATE UNIQUE INDEX handsPlayerSeat_idx ON Hands (handId, seatNo)"""
3641 if db_server == 'mysql':
3642 self.query['addPlayersIndex'] = """ALTER TABLE Players ADD UNIQUE INDEX name(name, siteId)"""
3643 elif db_server == 'postgresql':
3644 self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
3645 elif db_server == 'sqlite':
3646 self.query['addPlayersIndex'] = """CREATE UNIQUE INDEX name ON Players (name, siteId)"""
3648 if db_server == 'mysql':
3649 self.query['addTPlayersIndex'] = """ALTER TABLE TourneysPlayers ADD UNIQUE INDEX _tourneyId(tourneyId, playerId, entryId)"""
3650 elif db_server == 'postgresql':
3651 self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId, entryId)"""
3652 elif db_server == 'sqlite':
3653 self.query['addTPlayersIndex'] = """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId, entryId)"""
3655 if db_server == 'mysql':
3656 self.query['addStartCardsIndex'] = """ALTER TABLE StartCards ADD UNIQUE INDEX cards_idx (category, rank)"""
3657 elif db_server == 'postgresql':
3658 self.query['addStartCardsIndex'] = """CREATE UNIQUE INDEX cards_idx ON StartCards (category, rank)"""
3659 elif db_server == 'sqlite':
3660 self.query['addStartCardsIndex'] = """CREATE UNIQUE INDEX cards_idx ON StartCards (category, rank)"""
3662 if db_server == 'mysql':
3663 self.query['addSeatsIndex'] = """ALTER TABLE Hands ADD INDEX seats_idx (seats)"""
3664 elif db_server == 'postgresql':
3665 self.query['addSeatsIndex'] = """CREATE INDEX seats_idx ON Hands (seats)"""
3666 elif db_server == 'sqlite':
3667 self.query['addSeatsIndex'] = """CREATE INDEX seats_idx ON Hands (seats)"""
3669 if db_server == 'mysql':
3670 self.query['addPositionIndex'] = """ALTER TABLE HandsPlayers ADD INDEX position_idx (position)"""
3671 elif db_server == 'postgresql':
3672 self.query['addPositionIndex'] = """CREATE INDEX position_idx ON HandsPlayers (position)"""
3673 elif db_server == 'sqlite':
3674 self.query['addPositionIndex'] = """CREATE INDEX position_idx ON HandsPlayers (position)"""
3676 if db_server == 'mysql':
3677 self.query['addStartCashIndex'] = """ALTER TABLE HandsPlayers ADD INDEX cash_idx (startCash)"""
3678 elif db_server == 'postgresql':
3679 self.query['addStartCashIndex'] = """CREATE INDEX cash_idx ON HandsPlayers (startCash)"""
3680 elif db_server == 'sqlite':
3681 self.query['addStartCashIndex'] = """CREATE INDEX cash_idx ON HandsPlayers (startCash)"""
3683 if db_server == 'mysql':
3684 self.query['addEffStackIndex'] = """ALTER TABLE HandsPlayers ADD INDEX eff_stack_idx (effStack)"""
3685 elif db_server == 'postgresql':
3686 self.query['addEffStackIndex'] = """CREATE INDEX eff_stack_idx ON HandsPlayers (effStack)"""
3687 elif db_server == 'sqlite':
3688 self.query['addEffStackIndex'] = """CREATE INDEX eff_stack_idx ON HandsPlayers (effStack)"""
3690 if db_server == 'mysql':
3691 self.query['addTotalProfitIndex'] = """ALTER TABLE HandsPlayers ADD INDEX profit_idx (totalProfit)"""
3692 elif db_server == 'postgresql':
3693 self.query['addTotalProfitIndex'] = """CREATE INDEX profit_idx ON HandsPlayers (totalProfit)"""
3694 elif db_server == 'sqlite':
3695 self.query['addTotalProfitIndex'] = """CREATE INDEX profit_idx ON HandsPlayers (totalProfit)"""
3697 if db_server == 'mysql':
3698 self.query['addWinningsIndex'] = """ALTER TABLE HandsPlayers ADD INDEX winnings_idx (winnings)"""
3699 elif db_server == 'postgresql':
3700 self.query['addWinningsIndex'] = """CREATE INDEX winnings_idx ON HandsPlayers (winnings)"""
3701 elif db_server == 'sqlite':
3702 self.query['addWinningsIndex'] = """CREATE INDEX winnings_idx ON HandsPlayers (winnings)"""
3704 if db_server == 'mysql':
3705 self.query['addFinalPotIndex'] = """ALTER TABLE Hands ADD INDEX pot_idx (finalPot)"""
3706 elif db_server == 'postgresql':
3707 self.query['addFinalPotIndex'] = """CREATE INDEX pot_idx ON Hands (finalPot)"""
3708 elif db_server == 'sqlite':
3709 self.query['addFinalPotIndex'] = """CREATE INDEX pot_idx ON Hands (finalPot)"""
3711 if db_server == 'mysql':
3712 self.query['addStreetIndex'] = """ALTER TABLE HandsStove ADD INDEX street_idx (streetId, boardId)"""
3713 elif db_server == 'postgresql':
3714 self.query['addStreetIndex'] = """CREATE INDEX street_idx ON HandsStove (streetId, boardId)"""
3715 elif db_server == 'sqlite':
3716 self.query['addStreetIndex'] = """CREATE INDEX street_idx ON HandsStove (streetId, boardId)"""
3718 self.query['addSessionsCacheCompundIndex'] = """CREATE INDEX SessionsCache_Compound_idx ON SessionsCache(gametypeId, playerId)"""
3719 self.query['addTourneysCacheCompundIndex'] = """CREATE UNIQUE INDEX TourneysCache_Compound_idx ON TourneysCache(tourneyId, playerId)"""
3720 self.query['addHudCacheCompundIndex'] = """CREATE UNIQUE INDEX HudCache_Compound_idx ON HudCache(gametypeId, playerId, seats, position, tourneyTypeId, styleKey)"""
3722 self.query['addCardsCacheCompundIndex'] = """CREATE UNIQUE INDEX CardsCache_Compound_idx ON CardsCache(weekId, monthId, gametypeId, tourneyTypeId, playerId, startCards)"""
3723 self.query['addPositionsCacheCompundIndex'] = """CREATE UNIQUE INDEX PositionsCache_Compound_idx ON PositionsCache(weekId, monthId, gametypeId, tourneyTypeId, playerId, seats, maxPosition, position)"""
3725 # (left(file, 255)) is not valid syntax on postgres psycopg2 on windows (postgres v8.4)
3726 # error thrown is HINT: "No function matches the given name and argument types. You might need to add explicit type casts."
3727 # so we will just create the index with the full filename.
3728 if db_server == 'mysql':
3729 self.query['addFilesIndex'] = """CREATE UNIQUE INDEX index_file ON Files (file(255))"""
3730 elif db_server == 'postgresql':
3731 self.query['addFilesIndex'] = """CREATE UNIQUE INDEX index_file ON Files (file)"""
3732 elif db_server == 'sqlite':
3733 self.query['addFilesIndex'] = """CREATE UNIQUE INDEX index_file ON Files (file)"""
3735 self.query['addTableNameIndex'] = """CREATE INDEX index_tableName ON Hands (tableName)"""
3736 self.query['addPlayerNameIndex'] = """CREATE INDEX index_playerName ON Players (name)"""
3737 self.query['addPlayerHeroesIndex'] = """CREATE INDEX player_heroes ON Players (hero)"""
3739 self.query['get_last_hand'] = "select max(id) from Hands"
3741 self.query['get_last_date'] = "SELECT MAX(startTime) FROM Hands"
3743 self.query['get_first_date'] = "SELECT MIN(startTime) FROM Hands"
3745 self.query['get_player_id'] = """
3746 select Players.id AS player_id
3747 from Players, Sites
3748 where Players.name = %s
3749 and Sites.name = %s
3750 and Players.siteId = Sites.id
3751 """
3753 self.query['get_player_names'] = """
3754 select p.name
3755 from Players p
3756 where lower(p.name) like lower(%s)
3757 and (p.siteId = %s or %s = -1)
3758 """
3760 self.query['get_gameinfo_from_hid'] = """
3761 SELECT
3762 s.name,
3763 g.category,
3764 g.base,
3765 g.type,
3766 g.limitType,
3767 g.hilo,
3768 round(g.smallBlind / 100.0,2),
3769 round(g.bigBlind / 100.0,2),
3770 round(g.smallBet / 100.0,2),
3771 round(g.bigBet / 100.0,2),
3772 g.currency,
3773 h.gametypeId,
3774 g.split
3775 FROM
3776 Hands as h,
3777 Sites as s,
3778 Gametypes as g,
3779 HandsPlayers as hp,
3780 Players as p
3781 WHERE
3782 h.id = %s
3783 and g.id = h.gametypeId
3784 and hp.handId = h.id
3785 and p.id = hp.playerId
3786 and s.id = p.siteId
3787 limit 1
3788 """
3790 self.query['get_stats_from_hand'] = """
3791 SELECT hc.playerId AS player_id,
3792 hp.seatNo AS seat,
3793 p.name AS screen_name,
3794 sum(hc.n) AS n,
3795 sum(hc.street0VPIChance) AS vpip_opp,
3796 sum(hc.street0VPI) AS vpip,
3797 sum(hc.street0AggrChance) AS pfr_opp,
3798 sum(hc.street0Aggr) AS pfr,
3799 sum(hc.street0CalledRaiseChance) AS CAR_opp_0,
3800 sum(hc.street0CalledRaiseDone) AS CAR_0,
3801 sum(hc.street0_3BChance) AS TB_opp_0,
3802 sum(hc.street0_3BDone) AS TB_0,
3803 sum(hc.street0_4BChance) AS FB_opp_0,
3804 sum(hc.street0_4BDone) AS FB_0,
3805 sum(hc.street0_C4BChance) AS CFB_opp_0,
3806 sum(hc.street0_C4BDone) AS CFB_0,
3807 sum(hc.street0_FoldTo3BChance) AS F3B_opp_0,
3808 sum(hc.street0_FoldTo3BDone) AS F3B_0,
3809 sum(hc.street0_FoldTo4BChance) AS F4B_opp_0,
3810 sum(hc.street0_FoldTo4BDone) AS F4B_0,
3811 sum(hc.street0_SqueezeChance) AS SQZ_opp_0,
3812 sum(hc.street0_SqueezeDone) AS SQZ_0,
3813 sum(hc.raiseToStealChance) AS RTS_opp,
3814 sum(hc.raiseToStealDone) AS RTS,
3815 sum(hc.success_Steal) AS SUC_ST,
3816 sum(hc.street1Seen) AS saw_f,
3817 sum(hc.street1Seen) AS saw_1,
3818 sum(hc.street2Seen) AS saw_2,
3819 sum(hc.street3Seen) AS saw_3,
3820 sum(hc.street4Seen) AS saw_4,
3821 sum(hc.sawShowdown) AS sd,
3822 sum(hc.street1Aggr) AS aggr_1,
3823 sum(hc.street2Aggr) AS aggr_2,
3824 sum(hc.street3Aggr) AS aggr_3,
3825 sum(hc.street4Aggr) AS aggr_4,
3826 sum(hc.otherRaisedStreet1) AS was_raised_1,
3827 sum(hc.otherRaisedStreet2) AS was_raised_2,
3828 sum(hc.otherRaisedStreet3) AS was_raised_3,
3829 sum(hc.otherRaisedStreet4) AS was_raised_4,
3830 sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
3831 sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
3832 sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
3833 sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
3834 sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
3835 sum(hc.wonAtSD) AS wmsd,
3836 sum(hc.stealChance) AS steal_opp,
3837 sum(hc.stealDone) AS steal,
3838 sum(hc.foldSbToStealChance) AS SBstolen,
3839 sum(hc.foldedSbToSteal) AS SBnotDef,
3840 sum(hc.foldBbToStealChance) AS BBstolen,
3841 sum(hc.foldedBbToSteal) AS BBnotDef,
3842 sum(hc.street1CBChance) AS CB_opp_1,
3843 sum(hc.street1CBDone) AS CB_1,
3844 sum(hc.street2CBChance) AS CB_opp_2,
3845 sum(hc.street2CBDone) AS CB_2,
3846 sum(hc.street3CBChance) AS CB_opp_3,
3847 sum(hc.street3CBDone) AS CB_3,
3848 sum(hc.street4CBChance) AS CB_opp_4,
3849 sum(hc.street4CBDone) AS CB_4,
3850 sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
3851 sum(hc.foldToStreet1CBDone) AS f_cb_1,
3852 sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
3853 sum(hc.foldToStreet2CBDone) AS f_cb_2,
3854 sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
3855 sum(hc.foldToStreet3CBDone) AS f_cb_3,
3856 sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
3857 sum(hc.foldToStreet4CBDone) AS f_cb_4,
3858 sum(hc.totalProfit) AS net,
3859 sum(gt.bigblind * hc.n) AS bigblind,
3860 sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
3861 sum(hc.street1CheckCallDone) AS cc_1,
3862 sum(hc.street1CheckRaiseDone) AS cr_1,
3863 sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
3864 sum(hc.street2CheckCallDone) AS cc_2,
3865 sum(hc.street2CheckRaiseDone) AS cr_2,
3866 sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
3867 sum(hc.street3CheckCallDone) AS cc_3,
3868 sum(hc.street3CheckRaiseDone) AS cr_3,
3869 sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
3870 sum(hc.street4CheckCallDone) AS cc_4
3871 sum(hc.street4CheckRaiseDone) AS cr_4
3872 sum(hc.street0Calls) AS call_0,
3873 sum(hc.street1Calls) AS call_1,
3874 sum(hc.street2Calls) AS call_2,
3875 sum(hc.street3Calls) AS call_3,
3876 sum(hc.street4Calls) AS call_4,
3877 sum(hc.street0Bets) AS bet_0,
3878 sum(hc.street1Bets) AS bet_1,
3879 sum(hc.street2Bets) AS bet_2,
3880 sum(hc.street3Bets) AS bet_3,
3881 sum(hc.street4Bets) AS bet_4,
3882 sum(hc.street0Raises) AS raise_0,
3883 sum(hc.street1Raises) AS raise_1,
3884 sum(hc.street2Raises) AS raise_2,
3885 sum(hc.street3Raises) AS raise_3,
3886 sum(hc.street4Raises) AS raise_4
3887 FROM Hands h
3888 INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
3889 INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0
3890 AND hc.gametypeId+0 = h.gametypeId+0)
3891 INNER JOIN Players p ON (p.id = hp.PlayerId+0)
3892 INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId)
3893 WHERE h.id = %s
3894 AND hc.styleKey > %s
3895 /* styleKey is currently 'd' (for date) followed by a yyyymmdd
3896 date key. Set it to 0000000 or similar to get all records */
3897 /* also check activeseats here even if only 3 groups eg 2-3/4-6/7+
3898 e.g. could use a multiplier:
3899 AND h.seats > X / 1.25 and hp.seats < X * 1.25
3900 where X is the number of active players at the current table (and
3901 1.25 would be a config value so user could change it)
3902 */
3903 GROUP BY hc.PlayerId, hp.seatNo, p.name
3904 ORDER BY hc.PlayerId, hp.seatNo, p.name
3905 """
3907# same as above except stats are aggregated for all blind/limit levels
3908 self.query['get_stats_from_hand_aggregated'] = """
3909 /* explain query plan */
3910 SELECT hc.playerId AS player_id,
3911 max(case when hc.gametypeId = h.gametypeId
3912 then hp.seatNo
3913 else -1
3914 end) AS seat,
3915 p.name AS screen_name,
3916 sum(hc.n) AS n,
3917 sum(hc.street0VPIChance) AS vpip_opp,
3918 sum(hc.street0VPI) AS vpip,
3919 sum(hc.street0AggrChance) AS pfr_opp,
3920 sum(hc.street0Aggr) AS pfr,
3921 sum(hc.street0CalledRaiseChance) AS CAR_opp_0,
3922 sum(hc.street0CalledRaiseDone) AS CAR_0,
3923 sum(hc.street0_3BChance) AS TB_opp_0,
3924 sum(hc.street0_3BDone) AS TB_0,
3925 sum(hc.street0_4BChance) AS FB_opp_0,
3926 sum(hc.street0_4BDone) AS FB_0,
3927 sum(hc.street0_C4BChance) AS CFB_opp_0,
3928 sum(hc.street0_C4BDone) AS CFB_0,
3929 sum(hc.street0_FoldTo3BChance) AS F3B_opp_0,
3930 sum(hc.street0_FoldTo3BDone) AS F3B_0,
3931 sum(hc.street0_FoldTo4BChance) AS F4B_opp_0,
3932 sum(hc.street0_FoldTo4BDone) AS F4B_0,
3933 sum(hc.street0_SqueezeChance) AS SQZ_opp_0,
3934 sum(hc.street0_SqueezeDone) AS SQZ_0,
3935 sum(hc.raiseToStealChance) AS RTS_opp,
3936 sum(hc.raiseToStealDone) AS RTS,
3937 sum(hc.success_Steal) AS SUC_ST,
3938 sum(hc.street1Seen) AS saw_f,
3939 sum(hc.street1Seen) AS saw_1,
3940 sum(hc.street2Seen) AS saw_2,
3941 sum(hc.street3Seen) AS saw_3,
3942 sum(hc.street4Seen) AS saw_4,
3943 sum(hc.sawShowdown) AS sd,
3944 sum(hc.street1Aggr) AS aggr_1,
3945 sum(hc.street2Aggr) AS aggr_2,
3946 sum(hc.street3Aggr) AS aggr_3,
3947 sum(hc.street4Aggr) AS aggr_4,
3948 sum(hc.otherRaisedStreet1) AS was_raised_1,
3949 sum(hc.otherRaisedStreet2) AS was_raised_2,
3950 sum(hc.otherRaisedStreet3) AS was_raised_3,
3951 sum(hc.otherRaisedStreet4) AS was_raised_4,
3952 sum(hc.foldToOtherRaisedStreet1) AS f_freq_1,
3953 sum(hc.foldToOtherRaisedStreet2) AS f_freq_2,
3954 sum(hc.foldToOtherRaisedStreet3) AS f_freq_3,
3955 sum(hc.foldToOtherRaisedStreet4) AS f_freq_4,
3956 sum(hc.wonWhenSeenStreet1) AS w_w_s_1,
3957 sum(hc.wonAtSD) AS wmsd,
3958 sum(hc.stealChance) AS steal_opp,
3959 sum(hc.stealDone) AS steal,
3960 sum(hc.foldSbToStealChance) AS SBstolen,
3961 sum(hc.foldedSbToSteal) AS SBnotDef,
3962 sum(hc.foldBbToStealChance) AS BBstolen,
3963 sum(hc.foldedBbToSteal) AS BBnotDef,
3964 sum(hc.street1CBChance) AS CB_opp_1,
3965 sum(hc.street1CBDone) AS CB_1,
3966 sum(hc.street2CBChance) AS CB_opp_2,
3967 sum(hc.street2CBDone) AS CB_2,
3968 sum(hc.street3CBChance) AS CB_opp_3,
3969 sum(hc.street3CBDone) AS CB_3,
3970 sum(hc.street4CBChance) AS CB_opp_4,
3971 sum(hc.street4CBDone) AS CB_4,
3972 sum(hc.foldToStreet1CBChance) AS f_cb_opp_1,
3973 sum(hc.foldToStreet1CBDone) AS f_cb_1,
3974 sum(hc.foldToStreet2CBChance) AS f_cb_opp_2,
3975 sum(hc.foldToStreet2CBDone) AS f_cb_2,
3976 sum(hc.foldToStreet3CBChance) AS f_cb_opp_3,
3977 sum(hc.foldToStreet3CBDone) AS f_cb_3,
3978 sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
3979 sum(hc.foldToStreet4CBDone) AS f_cb_4,
3980 sum(hc.totalProfit) AS net,
3981 sum(gt.bigblind * hc.n) AS bigblind,
3982 sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
3983 sum(hc.street1CheckCallDone) AS cc_1,
3984 sum(hc.street1CheckRaiseDone) AS cr_1,
3985 sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
3986 sum(hc.street2CheckCallDone) AS cc_2,
3987 sum(hc.street2CheckRaiseDone) AS cr_2,
3988 sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3,
3989 sum(hc.street3CheckCallDone) AS cc_3,
3990 sum(hc.street3CheckRaiseDone) AS cr_3,
3991 sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4,
3992 sum(hc.street4CheckCallDone) AS cc_4,
3993 sum(hc.street4CheckRaiseDone) AS cr_4,
3994 sum(hc.street0Calls) AS call_0,
3995 sum(hc.street1Calls) AS call_1,
3996 sum(hc.street2Calls) AS call_2,
3997 sum(hc.street3Calls) AS call_3,
3998 sum(hc.street4Calls) AS call_4,
3999 sum(hc.street0Bets) AS bet_0,
4000 sum(hc.street1Bets) AS bet_1,
4001 sum(hc.street2Bets) AS bet_2,
4002 sum(hc.street3Bets) AS bet_3,
4003 sum(hc.street4Bets) AS bet_4,
4004 sum(hc.street0Raises) AS raise_0,
4005 sum(hc.street1Raises) AS raise_1,
4006 sum(hc.street2Raises) AS raise_2,
4007 sum(hc.street3Raises) AS raise_3,
4008 sum(hc.street4Raises) AS raise_4
4009 FROM Hands h
4010 INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
4011 INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
4012 INNER JOIN Players p ON (p.id = hc.playerId)
4013 INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId)
4014 WHERE h.id = %s
4015 AND ( /* 2 separate parts for hero and opponents */
4016 ( hp.playerId != %s
4017 AND hc.styleKey > %s
4018 AND hc.gametypeId+0 in
4019 (SELECT gt1.id from Gametypes gt1, Gametypes gt2
4020 WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
4021 AND gt1.type = gt2.type /* ring/tourney */
4022 AND gt1.category = gt2.category /* holdem/stud*/
4023 AND gt1.limittype = gt2.limittype /* fl/nl */
4024 AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
4025 AND gt1.bigblind >= gt2.bigblind / %s
4026 AND gt2.id = %s)
4027 AND hc.seats between %s and %s
4028 )
4029 OR
4030 ( hp.playerId = %s
4031 AND hc.styleKey > %s
4032 AND hc.gametypeId+0 in
4033 (SELECT gt1.id from Gametypes gt1, Gametypes gt2
4034 WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */
4035 AND gt1.type = gt2.type /* ring/tourney */
4036 AND gt1.category = gt2.category /* holdem/stud*/
4037 AND gt1.limittype = gt2.limittype /* fl/nl */
4038 AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */
4039 AND gt1.bigblind >= gt2.bigblind / %s
4040 AND gt2.id = %s)
4041 AND hc.seats between %s and %s
4042 )
4043 )
4044 GROUP BY hc.PlayerId, p.name
4045 ORDER BY hc.PlayerId, p.name
4046 """
4047 # NOTES on above cursor:
4048 # - Do NOT include %s inside query in a comment - the db api thinks
4049 # they are actual arguments.
4050 # - styleKey is currently 'd' (for date) followed by a yyyymmdd
4051 # date key. Set it to 0000000 or similar to get all records
4052 # Could also check activeseats here even if only 3 groups eg 2-3/4-6/7+
4053 # e.g. could use a multiplier:
4054 # AND h.seats > %s / 1.25 and hp.seats < %s * 1.25
4055 # where %s is the number of active players at the current table (and
4056 # 1.25 would be a config value so user could change it)
4058 if db_server == 'mysql':
4059 self.query['get_stats_from_hand_session'] = """
4060 SELECT hp.playerId AS player_id, /* playerId and seats must */
4061 h.seats AS seats, /* be first and second field */
4062 hp.handId AS hand_id,
4063 hp.seatNo AS seat,
4064 p.name AS screen_name,
4065 1 AS n,
4066 cast(hp2.street0VPIChance as SIGNED) AS vpip_opp,
4067 cast(hp2.street0VPI as SIGNED) AS vpip,
4068 cast(hp2.street0AggrChance as SIGNED) AS pfr_opp,
4069 cast(hp2.street0Aggr as SIGNED) AS pfr,
4070 cast(hp2.street0CalledRaiseChance as SIGNED) AS CAR_opp_0,
4071 cast(hp2.street0CalledRaiseDone as SIGNED) AS CAR_0,
4072 cast(hp2.street0_3BChance as SIGNED) AS TB_opp_0,
4073 cast(hp2.street0_3BDone as SIGNED) AS TB_0,
4074 cast(hp2.street0_4BChance as SIGNED) AS FB_opp_0,
4075 cast(hp2.street0_4BDone as SIGNED) AS FB_0,
4076 cast(hp2.street0_C4BChance as SIGNED) AS CFB_opp_0,
4077 cast(hp2.street0_C4BDone as SIGNED) AS CFB_0,
4078 cast(hp2.street0_FoldTo3BChance as SIGNED) AS F3B_opp_0,
4079 cast(hp2.street0_FoldTo3BDone as SIGNED) AS F3B_0,
4080 cast(hp2.street0_FoldTo4BChance as SIGNED) AS F4B_opp_0,
4081 cast(hp2.street0_FoldTo4BDone as SIGNED) AS F4B_0,
4082 cast(hp2.street0_SqueezeChance as SIGNED) AS SQZ_opp_0,
4083 cast(hp2.street0_SqueezeDone as SIGNED) AS SQZ_0,
4084 cast(hp2.raiseToStealChance as SIGNED) AS RTS_opp,
4085 cast(hp2.raiseToStealDone as SIGNED) AS RTS,
4086 cast(hp2.success_Steal as SIGNED) AS SUC_ST,
4087 cast(hp2.street1Seen as SIGNED) AS saw_f,
4088 cast(hp2.street1Seen as SIGNED) AS saw_1,
4089 cast(hp2.street2Seen as SIGNED) AS saw_2,
4090 cast(hp2.street3Seen as SIGNED) AS saw_3,
4091 cast(hp2.street4Seen as SIGNED) AS saw_4,
4092 cast(hp2.sawShowdown as SIGNED) AS sd,
4093 cast(hp2.street1Aggr as SIGNED) AS aggr_1,
4094 cast(hp2.street2Aggr as SIGNED) AS aggr_2,
4095 cast(hp2.street3Aggr as SIGNED) AS aggr_3,
4096 cast(hp2.street4Aggr as SIGNED) AS aggr_4,
4097 cast(hp2.otherRaisedStreet1 as SIGNED) AS was_raised_1,
4098 cast(hp2.otherRaisedStreet2 as SIGNED) AS was_raised_2,
4099 cast(hp2.otherRaisedStreet3 as SIGNED) AS was_raised_3,
4100 cast(hp2.otherRaisedStreet4 as SIGNED) AS was_raised_4,
4101 cast(hp2.foldToOtherRaisedStreet1 as SIGNED) AS f_freq_1,
4102 cast(hp2.foldToOtherRaisedStreet2 as SIGNED) AS f_freq_2,
4103 cast(hp2.foldToOtherRaisedStreet3 as SIGNED) AS f_freq_3,
4104 cast(hp2.foldToOtherRaisedStreet4 as SIGNED) AS f_freq_4,
4105 cast(hp2.wonWhenSeenStreet1 as SIGNED) AS w_w_s_1,
4106 cast(hp2.wonAtSD as SIGNED) AS wmsd,
4107 cast(hp2.stealChance as SIGNED) AS steal_opp,
4108 cast(hp2.stealDone as SIGNED) AS steal,
4109 cast(hp2.foldSbToStealChance as SIGNED) AS SBstolen,
4110 cast(hp2.foldedSbToSteal as SIGNED) AS SBnotDef,
4111 cast(hp2.foldBbToStealChance as SIGNED) AS BBstolen,
4112 cast(hp2.foldedBbToSteal as SIGNED) AS BBnotDef,
4113 cast(hp2.street1CBChance as SIGNED) AS CB_opp_1,
4114 cast(hp2.street1CBDone as SIGNED) AS CB_1,
4115 cast(hp2.street2CBChance as SIGNED) AS CB_opp_2,
4116 cast(hp2.street2CBDone as SIGNED) AS CB_2,
4117 cast(hp2.street3CBChance as SIGNED) AS CB_opp_3,
4118 cast(hp2.street3CBDone as SIGNED) AS CB_3,
4119 cast(hp2.street4CBChance as SIGNED) AS CB_opp_4,
4120 cast(hp2.street4CBDone as SIGNED) AS CB_4,
4121 cast(hp2.foldToStreet1CBChance as SIGNED) AS f_cb_opp_1,
4122 cast(hp2.foldToStreet1CBDone as SIGNED) AS f_cb_1,
4123 cast(hp2.foldToStreet2CBChance as SIGNED) AS f_cb_opp_2,
4124 cast(hp2.foldToStreet2CBDone as SIGNED) AS f_cb_2,
4125 cast(hp2.foldToStreet3CBChance as SIGNED) AS f_cb_opp_3,
4126 cast(hp2.foldToStreet3CBDone as SIGNED) AS f_cb_3,
4127 cast(hp2.foldToStreet4CBChance as SIGNED) AS f_cb_opp_4,
4128 cast(hp2.foldToStreet4CBDone as SIGNED) AS f_cb_4,
4129 cast(hp2.totalProfit as SIGNED) AS net,
4130 cast(gt.bigblind as SIGNED) AS bigblind,
4131 cast(hp2.street1CheckCallRaiseChance as SIGNED) AS ccr_opp_1,
4132 cast(hp2.street1CheckCallDone as SIGNED) AS cc_1,
4133 cast(hp2.street1CheckRaiseDone as SIGNED) AS cr_1,
4134 cast(hp2.street2CheckCallRaiseChance as SIGNED) AS ccr_opp_2,
4135 cast(hp2.street2CheckCallDone as SIGNED) AS cc_2,
4136 cast(hp2.street2CheckRaiseDone as SIGNED) AS cr_2,
4137 cast(hp2.street3CheckCallRaiseChance as SIGNED) AS ccr_opp_3,
4138 cast(hp2.street3CheckCallDone as SIGNED) AS cc_3,
4139 cast(hp2.street3CheckRaiseDone as SIGNED) AS cr_3,
4140 cast(hp2.street4CheckCallRaiseChance as SIGNED) AS ccr_opp_4,
4141 cast(hp2.street4CheckCallDone as SIGNED) AS cc_4,
4142 cast(hp2.street4CheckRaiseDone as SIGNED) AS cr_4,
4143 cast(hp2.street0Calls as SIGNED) AS call_0,
4144 cast(hp2.street1Calls as SIGNED) AS call_1,
4145 cast(hp2.street2Calls as SIGNED) AS call_2,
4146 cast(hp2.street3Calls as SIGNED) AS call_3,
4147 cast(hp2.street4Calls as SIGNED) AS call_4,
4148 cast(hp2.street0Bets as SIGNED) AS bet_0,
4149 cast(hp2.street1Bets as SIGNED) AS bet_1,
4150 cast(hp2.street2Bets as SIGNED) AS bet_2,
4151 cast(hp2.street3Bets as SIGNED) AS bet_3,
4152 cast(hp2.street4Bets as SIGNED) AS bet_4,
4153 cast(hp2.street0Raises as SIGNED) AS raise_0,
4154 cast(hp2.street1Raises as SIGNED) AS raise_1,
4155 cast(hp2.street2Raises as SIGNED) AS raise_2,
4156 cast(hp2.street3Raises as SIGNED) AS raise_3,
4157 cast(hp2.street4Raises as SIGNED) AS raise_4
4158 FROM
4159 Hands h
4160 INNER JOIN Hands h2 ON (h2.id >= %s AND h2.tableName = h.tableName)
4161 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
4162 INNER JOIN HandsPlayers hp2 ON (hp2.playerId+0 = hp.playerId+0 AND (hp2.handId = h2.id+0)) /* other hands by these players */
4163 INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
4164 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
4165 WHERE hp.handId = %s
4166 /* check activeseats once this data returned (don't want to do that here as it might
4167 assume a session ended just because the number of seats dipped for a few hands)
4168 */
4169 AND ( /* 2 separate parts for hero and opponents */
4170 ( hp2.playerId != %s
4171 AND h2.seats between %s and %s
4172 )
4173 OR
4174 ( hp2.playerId = %s
4175 AND h2.seats between %s and %s
4176 )
4177 )
4178 ORDER BY h.startTime desc, hp2.PlayerId
4179 /* order rows by handstart descending so that we can stop reading rows when
4180 there's a gap over X minutes between hands (ie. when we get back to start of
4181 the session */
4182 """
4183 elif db_server == 'postgresql':
4184 self.query['get_stats_from_hand_session'] = """
4185 SELECT hp.playerId AS player_id,
4186 hp.handId AS hand_id,
4187 hp.seatNo AS seat,
4188 p.name AS screen_name,
4189 h.seats AS seats,
4190 1 AS n,
4191 cast(hp2.street0VPIChance as <signed>integer) AS vpip_opp,
4192 cast(hp2.street0VPI as <signed>integer) AS vpip,
4193 cast(hp2.street0AggrChance as <signed>integer) AS pfr_opp,
4194 cast(hp2.street0Aggr as <signed>integer) AS pfr,
4195 cast(hp2.street0CalledRaiseChance as <signed>integer) AS CAR_opp_0,
4196 cast(hp2.street0CalledRaiseDone as <signed>integer) AS CAR_0,
4197 cast(hp2.street0_3BChance as <signed>integer) AS TB_opp_0,
4198 cast(hp2.street0_3BDone as <signed>integer) AS TB_0,
4199 cast(hp2.street0_4BChance as <signed>integer) AS FB_opp_0,
4200 cast(hp2.street0_4BDone as <signed>integer) AS FB_0,
4201 cast(hp2.street0_C4BChance as <signed>integer) AS CFB_opp_0,
4202 cast(hp2.street0_C4BDone as <signed>integer) AS CFB_0,
4203 cast(hp2.street0_FoldTo3BChance as <signed>integer) AS F3B_opp_0,
4204 cast(hp2.street0_FoldTo3BDone as <signed>integer) AS F3B_0,
4205 cast(hp2.street0_FoldTo4BChance as <signed>integer) AS F4B_opp_0,
4206 cast(hp2.street0_FoldTo4BDone as <signed>integer) AS F4B_0,
4207 cast(hp2.street0_SqueezeChance as <signed>integer) AS SQZ_opp_0,
4208 cast(hp2.street0_SqueezeDone as <signed>integer) AS SQZ_0,
4209 cast(hp2.raiseToStealChance as <signed>integer) AS RTS_opp,
4210 cast(hp2.raiseToStealDone as <signed>integer) AS RTS,
4211 cast(hp2.success_Steal as <signed>integer) AS SUC_ST,
4212 cast(hp2.street1Seen as <signed>integer) AS saw_f,
4213 cast(hp2.street1Seen as <signed>integer) AS saw_1,
4214 cast(hp2.street2Seen as <signed>integer) AS saw_2,
4215 cast(hp2.street3Seen as <signed>integer) AS saw_3,
4216 cast(hp2.street4Seen as <signed>integer) AS saw_4,
4217 cast(hp2.sawShowdown as <signed>integer) AS sd,
4218 cast(hp2.street1Aggr as <signed>integer) AS aggr_1,
4219 cast(hp2.street2Aggr as <signed>integer) AS aggr_2,
4220 cast(hp2.street3Aggr as <signed>integer) AS aggr_3,
4221 cast(hp2.street4Aggr as <signed>integer) AS aggr_4,
4222 cast(hp2.otherRaisedStreet1 as <signed>integer) AS was_raised_1,
4223 cast(hp2.otherRaisedStreet2 as <signed>integer) AS was_raised_2,
4224 cast(hp2.otherRaisedStreet3 as <signed>integer) AS was_raised_3,
4225 cast(hp2.otherRaisedStreet4 as <signed>integer) AS was_raised_4,
4226 cast(hp2.foldToOtherRaisedStreet1 as <signed>integer) AS f_freq_1,
4227 cast(hp2.foldToOtherRaisedStreet2 as <signed>integer) AS f_freq_2,
4228 cast(hp2.foldToOtherRaisedStreet3 as <signed>integer) AS f_freq_3,
4229 cast(hp2.foldToOtherRaisedStreet4 as <signed>integer) AS f_freq_4,
4230 cast(hp2.wonWhenSeenStreet1 as <signed>integer) AS w_w_s_1,
4231 cast(hp2.wonAtSD as <signed>integer) AS wmsd,
4232 cast(hp2.stealChance as <signed>integer) AS steal_opp,
4233 cast(hp2.stealDone as <signed>integer) AS steal,
4234 cast(hp2.foldSbToStealChance as <signed>integer) AS SBstolen,
4235 cast(hp2.foldedSbToSteal as <signed>integer) AS SBnotDef,
4236 cast(hp2.foldBbToStealChance as <signed>integer) AS BBstolen,
4237 cast(hp2.foldedBbToSteal as <signed>integer) AS BBnotDef,
4238 cast(hp2.street1CBChance as <signed>integer) AS CB_opp_1,
4239 cast(hp2.street1CBDone as <signed>integer) AS CB_1,
4240 cast(hp2.street2CBChance as <signed>integer) AS CB_opp_2,
4241 cast(hp2.street2CBDone as <signed>integer) AS CB_2,
4242 cast(hp2.street3CBChance as <signed>integer) AS CB_opp_3,
4243 cast(hp2.street3CBDone as <signed>integer) AS CB_3,
4244 cast(hp2.street4CBChance as <signed>integer) AS CB_opp_4,
4245 cast(hp2.street4CBDone as <signed>integer) AS CB_4,
4246 cast(hp2.foldToStreet1CBChance as <signed>integer) AS f_cb_opp_1,
4247 cast(hp2.foldToStreet1CBDone as <signed>integer) AS f_cb_1,
4248 cast(hp2.foldToStreet2CBChance as <signed>integer) AS f_cb_opp_2,
4249 cast(hp2.foldToStreet2CBDone as <signed>integer) AS f_cb_2,
4250 cast(hp2.foldToStreet3CBChance as <signed>integer) AS f_cb_opp_3,
4251 cast(hp2.foldToStreet3CBDone as <signed>integer) AS f_cb_3,
4252 cast(hp2.foldToStreet4CBChance as <signed>integer) AS f_cb_opp_4,
4253 cast(hp2.foldToStreet4CBDone as <signed>integer) AS f_cb_4,
4254 cast(hp2.totalProfit as <signed>bigint) AS net,
4255 cast(gt.bigblind as <signed>bigint) AS bigblind,
4256 cast(hp2.street1CheckCallRaiseChance as <signed>integer) AS ccr_opp_1,
4257 cast(hp2.street1CheckCallDone as <signed>integer) AS cc_1,
4258 cast(hp2.street1CheckRaiseDone as <signed>integer) AS cr_1,
4259 cast(hp2.street2CheckCallRaiseChance as <signed>integer) AS ccr_opp_2,
4260 cast(hp2.street2CheckCallDone as <signed>integer) AS cc_2,
4261 cast(hp2.street2CheckRaiseDone as <signed>integer) AS cr_2,
4262 cast(hp2.street3CheckCallRaiseChance as <signed>integer) AS ccr_opp_3,
4263 cast(hp2.street3CheckCallDone as <signed>integer) AS cc_3,
4264 cast(hp2.street3CheckRaiseDone as <signed>integer) AS cr_3,
4265 cast(hp2.street4CheckCallRaiseChance as <signed>integer) AS ccr_opp_4,
4266 cast(hp2.street4CheckCallDone as <signed>integer) AS cc_4,
4267 cast(hp2.street4CheckRaiseDone as <signed>integer) AS cr_4,
4268 cast(hp2.street0Calls as <signed>integer) AS call_0,
4269 cast(hp2.street1Calls as <signed>integer) AS call_1,
4270 cast(hp2.street2Calls as <signed>integer) AS call_2,
4271 cast(hp2.street3Calls as <signed>integer) AS call_3,
4272 cast(hp2.street4Calls as <signed>integer) AS call_4,
4273 cast(hp2.street0Bets as <signed>integer) AS bet_0,
4274 cast(hp2.street1Bets as <signed>integer) AS bet_1,
4275 cast(hp2.street2Bets as <signed>integer) AS bet_2,
4276 cast(hp2.street3Bets as <signed>integer) AS bet_3,
4277 cast(hp2.street4Bets as <signed>integer) AS bet_4,
4278 cast(hp2.street0Raises as <signed>integer) AS raise_0,
4279 cast(hp2.street1Raises as <signed>integer) AS raise_1,
4280 cast(hp2.street2Raises as <signed>integer) AS raise_2,
4281 cast(hp2.street3Raises as <signed>integer) AS raise_3,
4282 cast(hp2.street4Raises as <signed>integer) AS raise_4
4283 FROM Hands h /* this hand */
4284 INNER JOIN Hands h2 ON ( h2.id >= %s /* other hands */
4285 AND h2.tableName = h.tableName)
4286 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
4287 INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
4288 AND hp2.handId = h2.id) /* other hands by these players */
4289 INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
4290 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
4291 WHERE h.id = %s
4292 /* check activeseats once this data returned (don't want to do that here as it might
4293 assume a session ended just because the number of seats dipped for a few hands)
4294 */
4295 AND ( /* 2 separate parts for hero and opponents */
4296 ( hp2.playerId != %s
4297 AND h2.seats between %s and %s
4298 )
4299 OR
4300 ( hp2.playerId = %s
4301 AND h2.seats between %s and %s
4302 )
4303 )
4304 ORDER BY h.startTime desc, hp2.PlayerId
4305 /* order rows by handstart descending so that we can stop reading rows when
4306 there's a gap over X minutes between hands (ie. when we get back to start of
4307 the session */
4308 """
4309 elif db_server == 'sqlite':
4310 self.query['get_stats_from_hand_session'] = """
4311 SELECT hp.playerId AS player_id,
4312 hp.handId AS hand_id,
4313 hp.seatNo AS seat,
4314 p.name AS screen_name,
4315 h.seats AS seats,
4316 1 AS n,
4317 cast(hp2.street0VPIChance as <signed>integer) AS vpip_opp,
4318 cast(hp2.street0VPI as <signed>integer) AS vpip,
4319 cast(hp2.street0AggrChance as <signed>integer) AS pfr_opp,
4320 cast(hp2.street0Aggr as <signed>integer) AS pfr,
4321 cast(hp2.street0CalledRaiseChance as <signed>integer) AS CAR_opp_0,
4322 cast(hp2.street0CalledRaiseDone as <signed>integer) AS CAR_0,
4323 cast(hp2.street0_3BChance as <signed>integer) AS TB_opp_0,
4324 cast(hp2.street0_3BDone as <signed>integer) AS TB_0,
4325 cast(hp2.street0_4BChance as <signed>integer) AS FB_opp_0,
4326 cast(hp2.street0_4BDone as <signed>integer) AS FB_0,
4327 cast(hp2.street0_C4BChance as <signed>integer) AS CFB_opp_0,
4328 cast(hp2.street0_C4BDone as <signed>integer) AS CFB_0,
4329 cast(hp2.street0_FoldTo3BChance as <signed>integer) AS F3B_opp_0,
4330 cast(hp2.street0_FoldTo3BDone as <signed>integer) AS F3B_0,
4331 cast(hp2.street0_FoldTo4BChance as <signed>integer) AS F4B_opp_0,
4332 cast(hp2.street0_FoldTo4BDone as <signed>integer) AS F4B_0,
4333 cast(hp2.street0_SqueezeChance as <signed>integer) AS SQZ_opp_0,
4334 cast(hp2.street0_SqueezeDone as <signed>integer) AS SQZ_0,
4335 cast(hp2.raiseToStealChance as <signed>integer) AS RTS_opp,
4336 cast(hp2.raiseToStealDone as <signed>integer) AS RTS,
4337 cast(hp2.success_Steal as <signed>integer) AS SUC_ST,
4338 cast(hp2.street1Seen as <signed>integer) AS saw_f,
4339 cast(hp2.street1Seen as <signed>integer) AS saw_1,
4340 cast(hp2.street2Seen as <signed>integer) AS saw_2,
4341 cast(hp2.street3Seen as <signed>integer) AS saw_3,
4342 cast(hp2.street4Seen as <signed>integer) AS saw_4,
4343 cast(hp2.sawShowdown as <signed>integer) AS sd,
4344 cast(hp2.street1Aggr as <signed>integer) AS aggr_1,
4345 cast(hp2.street2Aggr as <signed>integer) AS aggr_2,
4346 cast(hp2.street3Aggr as <signed>integer) AS aggr_3,
4347 cast(hp2.street4Aggr as <signed>integer) AS aggr_4,
4348 cast(hp2.otherRaisedStreet1 as <signed>integer) AS was_raised_1,
4349 cast(hp2.otherRaisedStreet2 as <signed>integer) AS was_raised_2,
4350 cast(hp2.otherRaisedStreet3 as <signed>integer) AS was_raised_3,
4351 cast(hp2.otherRaisedStreet4 as <signed>integer) AS was_raised_4,
4352 cast(hp2.foldToOtherRaisedStreet1 as <signed>integer) AS f_freq_1,
4353 cast(hp2.foldToOtherRaisedStreet2 as <signed>integer) AS f_freq_2,
4354 cast(hp2.foldToOtherRaisedStreet3 as <signed>integer) AS f_freq_3,
4355 cast(hp2.foldToOtherRaisedStreet4 as <signed>integer) AS f_freq_4,
4356 cast(hp2.wonWhenSeenStreet1 as <signed>integer) AS w_w_s_1,
4357 cast(hp2.wonAtSD as <signed>integer) AS wmsd,
4358 cast(hp2.stealChance as <signed>integer) AS steal_opp,
4359 cast(hp2.stealDone as <signed>integer) AS steal,
4360 cast(hp2.foldSbToStealChance as <signed>integer) AS SBstolen,
4361 cast(hp2.foldedSbToSteal as <signed>integer) AS SBnotDef,
4362 cast(hp2.foldBbToStealChance as <signed>integer) AS BBstolen,
4363 cast(hp2.foldedBbToSteal as <signed>integer) AS BBnotDef,
4364 cast(hp2.street1CBChance as <signed>integer) AS CB_opp_1,
4365 cast(hp2.street1CBDone as <signed>integer) AS CB_1,
4366 cast(hp2.street2CBChance as <signed>integer) AS CB_opp_2,
4367 cast(hp2.street2CBDone as <signed>integer) AS CB_2,
4368 cast(hp2.street3CBChance as <signed>integer) AS CB_opp_3,
4369 cast(hp2.street3CBDone as <signed>integer) AS CB_3,
4370 cast(hp2.street4CBChance as <signed>integer) AS CB_opp_4,
4371 cast(hp2.street4CBDone as <signed>integer) AS CB_4,
4372 cast(hp2.foldToStreet1CBChance as <signed>integer) AS f_cb_opp_1,
4373 cast(hp2.foldToStreet1CBDone as <signed>integer) AS f_cb_1,
4374 cast(hp2.foldToStreet2CBChance as <signed>integer) AS f_cb_opp_2,
4375 cast(hp2.foldToStreet2CBDone as <signed>integer) AS f_cb_2,
4376 cast(hp2.foldToStreet3CBChance as <signed>integer) AS f_cb_opp_3,
4377 cast(hp2.foldToStreet3CBDone as <signed>integer) AS f_cb_3,
4378 cast(hp2.foldToStreet4CBChance as <signed>integer) AS f_cb_opp_4,
4379 cast(hp2.foldToStreet4CBDone as <signed>integer) AS f_cb_4,
4380 cast(hp2.totalProfit as <signed>integer) AS net,
4381 cast(gt.bigblind as <signed>integer) AS bigblind,
4382 cast(hp2.street1CheckCallRaiseChance as <signed>integer) AS ccr_opp_1,
4383 cast(hp2.street1CheckCallDone as <signed>integer) AS cc_1,
4384 cast(hp2.street1CheckRaiseDone as <signed>integer) AS cr_1,
4385 cast(hp2.street2CheckCallRaiseChance as <signed>integer) AS ccr_opp_2,
4386 cast(hp2.street2CheckCallDone as <signed>integer) AS cc_2,
4387 cast(hp2.street2CheckRaiseDone as <signed>integer) AS cr_2,
4388 cast(hp2.street3CheckCallRaiseChance as <signed>integer) AS ccr_opp_3,
4389 cast(hp2.street3CheckCallDone as <signed>integer) AS cc_3,
4390 cast(hp2.street3CheckRaiseDone as <signed>integer) AS cr_3,
4391 cast(hp2.street4CheckCallRaiseChance as <signed>integer) AS ccr_opp_4,
4392 cast(hp2.street4CheckCallDone as <signed>integer) AS cc_4,
4393 cast(hp2.street4CheckRaiseDone as <signed>integer) AS cr_4,
4394 cast(hp2.street0Calls as <signed>integer) AS call_0,
4395 cast(hp2.street1Calls as <signed>integer) AS call_1,
4396 cast(hp2.street2Calls as <signed>integer) AS call_2,
4397 cast(hp2.street3Calls as <signed>integer) AS call_3,
4398 cast(hp2.street4Calls as <signed>integer) AS call_4,
4399 cast(hp2.street0Bets as <signed>integer) AS bet_0,
4400 cast(hp2.street1Bets as <signed>integer) AS bet_1,
4401 cast(hp2.street2Bets as <signed>integer) AS bet_2,
4402 cast(hp2.street3Bets as <signed>integer) AS bet_3,
4403 cast(hp2.street4Bets as <signed>integer) AS bet_4,
4404 cast(hp2.street0Raises as <signed>integer) AS raise_0,
4405 cast(hp2.street1Raises as <signed>integer) AS raise_1,
4406 cast(hp2.street2Raises as <signed>integer) AS raise_2,
4407 cast(hp2.street3Raises as <signed>integer) AS raise_3,
4408 cast(hp2.street4Raises as <signed>integer) AS raise_4
4409 FROM Hands h /* this hand */
4410 INNER JOIN Hands h2 ON ( h2.id >= %s /* other hands */
4411 AND h2.tableName = h.tableName)
4412 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
4413 INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
4414 AND hp2.handId = h2.id) /* other hands by these players */
4415 INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
4416 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
4417 WHERE h.id = %s
4418 /* check activeseats once this data returned (don't want to do that here as it might
4419 assume a session ended just because the number of seats dipped for a few hands)
4420 */
4421 AND ( /* 2 separate parts for hero and opponents */
4422 ( hp2.playerId != %s
4423 AND h2.seats between %s and %s
4424 )
4425 OR
4426 ( hp2.playerId = %s
4427 AND h2.seats between %s and %s
4428 )
4429 )
4430 ORDER BY h.startTime desc, hp2.PlayerId
4431 /* order rows by handstart descending so that we can stop reading rows when
4432 there's a gap over X minutes between hands (ie. when we get back to start of
4433 the session */
4434 """
4436 self.query['get_players_from_hand'] = """
4437 SELECT HandsPlayers.playerId, seatNo, name
4438 FROM HandsPlayers INNER JOIN Players ON (HandsPlayers.playerId = Players.id)
4439 WHERE handId = %s
4440 """
4441# WHERE handId = %s AND Players.id LIKE %s
4443 self.query['get_winners_from_hand'] = """
4444 SELECT name, winnings
4445 FROM HandsPlayers, Players
4446 WHERE winnings > 0
4447 AND Players.id = HandsPlayers.playerId
4448 AND handId = %s;
4449 """
4451 self.query['get_table_name'] = """
4452 SELECT h.tableName, gt.maxSeats, gt.category, gt.type, gt.fast, s.id, s.name
4453 , count(1) as numseats
4454 FROM Hands h, Gametypes gt, Sites s, HandsPlayers hp
4455 WHERE h.id = %s
4456 AND gt.id = h.gametypeId
4457 AND s.id = gt.siteID
4458 AND hp.handId = h.id
4459 GROUP BY h.tableName, gt.maxSeats, gt.category, gt.type, gt.fast, s.id, s.name
4460 """
4462 self.query['get_actual_seat'] = """
4463 select seatNo
4464 from HandsPlayers
4465 where HandsPlayers.handId = %s
4466 and HandsPlayers.playerId = (select Players.id from Players
4467 where Players.name = %s)
4468 """
4470 self.query['get_cards'] = """
4471/*
4472 changed to activate mucked card display in draw games
4473 in draw games, card6->card20 contain 3 sets of 5 cards at each draw
4475 CASE code searches from the highest card number (latest draw) and when
4476 it finds a non-zero card, it returns that set of data
4477*/
4478 SELECT
4479 seatNo AS seat_number,
4480 CASE Gametypes.base
4481 when 'draw' then COALESCE(NULLIF(card16,0), NULLIF(card11,0), NULLIF(card6,0), card1)
4482 else card1
4483 end card1,
4484 CASE Gametypes.base
4485 when 'draw' then COALESCE(NULLIF(card17,0), NULLIF(card12,0), NULLIF(card7,0), card2)
4486 else card2
4487 end card2,
4488 CASE Gametypes.base
4489 when 'draw' then COALESCE(NULLIF(card18,0), NULLIF(card13,0), NULLIF(card8,0), card3)
4490 else card3
4491 end card3,
4492 CASE Gametypes.base
4493 when 'draw' then COALESCE(NULLIF(card19,0), NULLIF(card14,0), NULLIF(card9,0), card4)
4494 else card4
4495 end card4,
4496 CASE Gametypes.base
4497 when 'draw' then COALESCE(NULLIF(card20,0), NULLIF(card15,0), NULLIF(card10,0), card5)
4498 else card5
4499 end card5,
4500 CASE Gametypes.base
4501 when 'draw' then 0
4502 else card6
4503 end card6,
4504 CASE Gametypes.base
4505 when 'draw' then 0
4506 else card7
4507 end card7
4509 FROM HandsPlayers, Hands, Gametypes
4510 WHERE handID = %s
4511 AND HandsPlayers.handId=Hands.id
4512 AND Hands.gametypeId = Gametypes.id
4513 ORDER BY seatNo
4514 """
4516 self.query['get_common_cards'] = """
4517 select
4518 boardcard1,
4519 boardcard2,
4520 boardcard3,
4521 boardcard4,
4522 boardcard5
4523 from Hands
4524 where Id = %s
4525 """
4527 if db_server == 'mysql':
4528 self.query['get_hand_1day_ago'] = """
4529 select coalesce(max(id),0)
4530 from Hands
4531 where startTime < date_sub(utc_timestamp(), interval '1' day)"""
4532 elif db_server == 'postgresql':
4533 self.query['get_hand_1day_ago'] = """
4534 select coalesce(max(id),0)
4535 from Hands
4536 where startTime < now() at time zone 'UTC' - interval '1 day'"""
4537 elif db_server == 'sqlite':
4538 self.query['get_hand_1day_ago'] = """
4539 select coalesce(max(id),0)
4540 from Hands
4541 where startTime < datetime(strftime('%J', 'now') - 1)"""
4543 # not used yet ...
4544 # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id
4545 if db_server == 'mysql':
4546 self.query['get_date_nhands_ago'] = """
4547 select concat( 'd', date_format(max(h.startTime), '%Y%m%d') )
4548 from (select hp.playerId
4549 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
4550 from HandsPlayers hp
4551 where hp.playerId = %s
4552 group by hp.playerId) hp2
4553 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
4554 and hp3.playerId = hp2.playerId)
4555 inner join Hands h on (h.id = hp3.handId)
4556 """
4557 elif db_server == 'postgresql':
4558 self.query['get_date_nhands_ago'] = """
4559 select 'd' || to_char(max(h3.startTime), 'YYMMDD')
4560 from (select hp.playerId
4561 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
4562 from HandsPlayers hp
4563 where hp.playerId = %s
4564 group by hp.playerId) hp2
4565 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
4566 and hp3.playerId = hp2.playerId)
4567 inner join Hands h on (h.id = hp3.handId)
4568 """
4569 elif db_server == 'sqlite': # untested guess at query:
4570 self.query['get_date_nhands_ago'] = """
4571 select 'd' || strftime(max(h3.startTime), 'YYMMDD')
4572 from (select hp.playerId
4573 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx
4574 from HandsPlayers hp
4575 where hp.playerId = %s
4576 group by hp.playerId) hp2
4577 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx
4578 and hp3.playerId = hp2.playerId)
4579 inner join Hands h on (h.id = hp3.handId)
4580 """
4582 # Used in *Filters:
4583 #self.query['getLimits'] = already defined further up
4584 self.query['getLimits2'] = """SELECT DISTINCT type, limitType, bigBlind
4585 from Gametypes
4586 ORDER by type, limitType DESC, bigBlind DESC"""
4587 self.query['getLimits3'] = """select DISTINCT type
4588 , gt.limitType
4589 , case type
4590 when 'ring' then bigBlind
4591- else buyin
4592- end as bb_or_buyin
4593 from Gametypes gt
4594 cross join TourneyTypes tt
4595 order by type, gt.limitType DESC, bb_or_buyin DESC"""
4596# self.query['getCashLimits'] = """select DISTINCT type
4597# , limitType
4598# , bigBlind as bb_or_buyin
4599# from Gametypes gt
4600# WHERE type = 'ring'
4601# order by type, limitType DESC, bb_or_buyin DESC"""
4603 self.query['getCashLimits'] = """select DISTINCT type
4604 , limitType
4605 , bigBlind as bb_or_buyin
4606 from Gametypes gt
4607 WHERE type = 'ring'
4608 order by type, limitType DESC, bb_or_buyin DESC"""
4610 self.query['getPositions'] = """select distinct position
4611 from HandsPlayers gt
4612 order by position"""
4614 #FIXME: Some stats not added to DetailedStats (miss raise to steal)
4615 if db_server == 'mysql':
4616 self.query['playerDetailedStats'] = """
4617 select <hgametypeId> AS hgametypeid
4618 ,<playerName> AS pname
4619 ,gt.base
4620 ,gt.category
4621 ,upper(gt.limitType) AS limittype
4622 ,s.name
4623 ,min(gt.bigBlind) AS minbigblind
4624 ,max(gt.bigBlind) AS maxbigblind
4625 ,gt.ante AS ante
4626 ,gt.currency AS currency
4627 /*,<hcgametypeId> AS gtid*/
4628 ,<position> AS plposition
4629 ,gt.fast AS fast
4630 ,count(1) AS n
4631 ,case when sum(cast(hp.street0VPIChance as SIGNED)) = 0 then -999
4632 else 100.0*sum(cast(hp.street0VPI as SIGNED))/sum(cast(hp.street0VPIChance as SIGNED))
4633 end AS vpip
4634 ,case when sum(cast(hp.street0AggrChance as SIGNED)) = 0 then -999
4635 else 100.0*sum(cast(hp.street0Aggr as SIGNED))/sum(cast(hp.street0AggrChance as SIGNED))
4636 end AS pfr
4637 ,case when sum(cast(hp.street0CalledRaiseChance as SIGNED)) = 0 then -999
4638 else 100.0*sum(cast(hp.street0CalledRaiseDone as SIGNED))/sum(cast(hp.street0CalledRaiseChance as SIGNED))
4639 end AS car0
4640 ,case when sum(cast(hp.street0_3Bchance as SIGNED)) = 0 then -999
4641 else 100.0*sum(cast(hp.street0_3Bdone as SIGNED))/sum(cast(hp.street0_3Bchance as SIGNED))
4642 end AS pf3
4643 ,case when sum(cast(hp.street0_4Bchance as SIGNED)) = 0 then -999
4644 else 100.0*sum(cast(hp.street0_4Bdone as SIGNED))/sum(cast(hp.street0_4Bchance as SIGNED))
4645 end AS pf4
4646 ,case when sum(cast(hp.street0_FoldTo3Bchance as SIGNED)) = 0 then -999
4647 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as SIGNED))/sum(cast(hp.street0_FoldTo3Bchance as SIGNED))
4648 end AS pff3
4649 ,case when sum(cast(hp.street0_FoldTo4Bchance as SIGNED)) = 0 then -999
4650 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as SIGNED))/sum(cast(hp.street0_FoldTo4Bchance as SIGNED))
4651 end AS pff4
4653 ,case when sum(cast(hp.raiseFirstInChance as SIGNED)) = 0 then -999
4654 else 100.0 * sum(cast(hp.raisedFirstIn as SIGNED)) /
4655 sum(cast(hp.raiseFirstInChance as SIGNED))
4656 end AS rfi
4657 ,case when sum(cast(hp.stealChance as SIGNED)) = 0 then -999
4658 else 100.0 * sum(cast(hp.stealDone as SIGNED)) /
4659 sum(cast(hp.stealChance as SIGNED))
4660 end AS steals
4661 ,case when sum(cast(hp.stealDone as SIGNED)) = 0 then -999
4662 else 100.0 * sum(cast(hp.success_Steal as SIGNED)) /
4663 sum(cast(hp.stealDone as SIGNED))
4664 end AS suc_steal
4665 ,100.0*sum(cast(hp.street1Seen as SIGNED))/count(1) AS saw_f
4666 ,100.0*sum(cast(hp.sawShowdown as SIGNED))/count(1) AS sawsd
4667 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999
4668 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as SIGNED))/sum(cast(hp.street1Seen as SIGNED))
4669 end AS wmsf
4670 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999
4671 else 100.0*sum(cast(hp.sawShowdown as SIGNED))/sum(cast(hp.street1Seen as SIGNED))
4672 end AS wtsdwsf
4673 ,case when sum(cast(hp.sawShowdown as SIGNED)) = 0 then -999
4674 else 100.0*sum(cast(hp.wonAtSD as SIGNED))/sum(cast(hp.sawShowdown as SIGNED))
4675 end AS wmsd
4676 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999
4677 else 100.0*sum(cast(hp.street1Aggr as SIGNED))/sum(cast(hp.street1Seen as SIGNED))
4678 end AS flafq
4679 ,case when sum(cast(hp.street2Seen as SIGNED)) = 0 then -999
4680 else 100.0*sum(cast(hp.street2Aggr as SIGNED))/sum(cast(hp.street2Seen as SIGNED))
4681 end AS tuafq
4682 ,case when sum(cast(hp.street3Seen as SIGNED)) = 0 then -999
4683 else 100.0*sum(cast(hp.street3Aggr as SIGNED))/sum(cast(hp.street3Seen as SIGNED))
4684 end AS rvafq
4685 ,case when sum(cast(hp.street1Seen as SIGNED))+sum(cast(hp.street2Seen as SIGNED))+sum(cast(hp.street3Seen as SIGNED)) = 0 then -999
4686 else 100.0*(sum(cast(hp.street1Aggr as SIGNED))+sum(cast(hp.street2Aggr as SIGNED))+sum(cast(hp.street3Aggr as SIGNED)))
4687 /(sum(cast(hp.street1Seen as SIGNED))+sum(cast(hp.street2Seen as SIGNED))+sum(cast(hp.street3Seen as SIGNED)))
4688 end AS pofafq
4689 ,case when sum(cast(hp.street1Calls as SIGNED))+ sum(cast(hp.street2Calls as SIGNED))+ sum(cast(hp.street3Calls as SIGNED))+ sum(cast(hp.street4Calls as SIGNED)) = 0 then -999
4690 else (sum(cast(hp.street1Aggr as SIGNED)) + sum(cast(hp.street2Aggr as SIGNED)) + sum(cast(hp.street3Aggr as SIGNED)) + sum(cast(hp.street4Aggr as SIGNED)))
4691 /(0.0+sum(cast(hp.street1Calls as SIGNED))+ sum(cast(hp.street2Calls as SIGNED))+ sum(cast(hp.street3Calls as SIGNED))+ sum(cast(hp.street4Calls as SIGNED)))
4692 end AS aggfac
4693 ,100.0*(sum(cast(hp.street1Aggr as SIGNED)) + sum(cast(hp.street2Aggr as SIGNED)) + sum(cast(hp.street3Aggr as SIGNED)) + sum(cast(hp.street4Aggr as SIGNED)))
4694 / ((sum(cast(hp.foldToOtherRaisedStreet1 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet2 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet3 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet4 as SIGNED))) +
4695 (sum(cast(hp.street1Calls as SIGNED))+ sum(cast(hp.street2Calls as SIGNED))+ sum(cast(hp.street3Calls as SIGNED))+ sum(cast(hp.street4Calls as SIGNED))) +
4696 (sum(cast(hp.street1Aggr as SIGNED)) + sum(cast(hp.street2Aggr as SIGNED)) + sum(cast(hp.street3Aggr as SIGNED)) + sum(cast(hp.street4Aggr as SIGNED))) )
4697 AS aggfrq
4698 ,100.0*(sum(cast(hp.street1CBDone as SIGNED)) + sum(cast(hp.street2CBDone as SIGNED)) + sum(cast(hp.street3CBDone as SIGNED)) + sum(cast(hp.street4CBDone as SIGNED)))
4699 / (sum(cast(hp.street1CBChance as SIGNED))+ sum(cast(hp.street2CBChance as SIGNED))+ sum(cast(hp.street3CBChance as SIGNED))+ sum(cast(hp.street4CBChance as SIGNED)))
4700 AS conbet
4701 ,sum(hp.totalProfit)/100.0 AS net
4702 ,sum(hp.rake)/100.0 AS rake
4703 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100
4704 ,avg(hp.totalProfit)/100.0 AS profitperhand
4705 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr
4706 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr
4707 ,avg(h.seats+0.0) AS avgseats
4708 ,variance(hp.totalProfit/100.0) AS variance
4709 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev
4710 from HandsPlayers hp
4711 inner join Hands h on (h.id = hp.handId)
4712 inner join Gametypes gt on (gt.Id = h.gametypeId)
4713 inner join Sites s on (s.Id = gt.siteId)
4714 inner join Players p on (p.Id = hp.playerId)
4715 where hp.playerId in <player_test>
4716 <game_test>
4717 <site_test>
4718 <currency_test>
4719 /*and hp.tourneysPlayersId IS NULL*/
4720 and h.seats <seats_test>
4721 <flagtest>
4722 <cardstest>
4723 <gtbigBlind_test>
4724 and date_format(h.startTime, '%Y-%m-%d %T') <datestest>
4725 group by hgametypeId
4726 ,pname
4727 ,gt.base
4728 ,gt.category
4729 <groupbyseats>
4730 ,plposition
4731 ,upper(gt.limitType)
4732 ,gt.fast
4733 ,s.name
4734 having 1 = 1 <havingclause>
4735 order by pname
4736 ,gt.base
4737 ,gt.category
4738 <orderbyseats>
4739 ,case <position> when 'B' then 'B'
4740 when 'S' then 'S'
4741 else concat('Z', <position>)
4742 end
4743 <orderbyhgametypeId>
4744 ,upper(gt.limitType) desc
4745 ,maxbigblind desc
4746 ,gt.fast
4747 ,s.name
4748 """
4749 elif db_server == 'postgresql':
4750 self.query['playerDetailedStats'] = """
4751 select <hgametypeId> AS hgametypeid
4752 ,<playerName> AS pname
4753 ,gt.base
4754 ,gt.category
4755 ,upper(gt.limitType) AS limittype
4756 ,s.name
4757 ,min(gt.bigBlind) AS minbigblind
4758 ,max(gt.bigBlind) AS maxbigblind
4759 ,gt.ante AS ante
4760 ,gt.currency AS currency
4761 /*,<hcgametypeId> AS gtid*/
4762 ,<position> AS plposition
4763 ,gt.fast AS fast
4764 ,count(1) AS n
4765 ,case when sum(cast(hp.street0VPIChance as <signed>integer)) = 0 then -999
4766 else 100.0*sum(cast(hp.street0VPI as <signed>integer))/sum(cast(hp.street0VPIChance as <signed>integer))
4767 end AS vpip
4768 ,case when sum(cast(hp.street0AggrChance as <signed>integer)) = 0 then -999
4769 else 100.0*sum(cast(hp.street0Aggr as <signed>integer))/sum(cast(hp.street0AggrChance as <signed>integer))
4770 end AS pfr
4771 ,case when sum(cast(hp.street0CalledRaiseChance as <signed>integer)) = 0 then -999
4772 else 100.0*sum(cast(hp.street0CalledRaiseDone as <signed>integer))/sum(cast(hp.street0CalledRaiseChance as <signed>integer))
4773 end AS car0
4774 ,case when sum(cast(hp.street0_3Bchance as <signed>integer)) = 0 then -999
4775 else 100.0*sum(cast(hp.street0_3Bdone as <signed>integer))/sum(cast(hp.street0_3Bchance as <signed>integer))
4776 end AS pf3
4777 ,case when sum(cast(hp.street0_4Bchance as <signed>integer)) = 0 then -999
4778 else 100.0*sum(cast(hp.street0_4Bdone as <signed>integer))/sum(cast(hp.street0_4Bchance as <signed>integer))
4779 end AS pf4
4780 ,case when sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) = 0 then -999
4781 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo3Bchance as <signed>integer))
4782 end AS pff3
4783 ,case when sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) = 0 then -999
4784 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo4Bchance as <signed>integer))
4785 end AS pff4
4786 ,case when sum(cast(hp.raiseFirstInChance as <signed>integer)) = 0 then -999
4787 else 100.0 * sum(cast(hp.raisedFirstIn as <signed>integer)) /
4788 sum(cast(hp.raiseFirstInChance as <signed>integer))
4789 end AS rfi
4790 ,case when sum(cast(hp.stealChance as <signed>integer)) = 0 then -999
4791 else 100.0 * sum(cast(hp.stealDone as <signed>integer)) /
4792 sum(cast(hp.stealChance as <signed>integer))
4793 end AS steals
4794 ,case when sum(cast(hp.stealDone as <signed>integer)) = 0 then -999
4795 else 100.0 * sum(cast(hp.success_Steal as <signed>integer)) /
4796 sum(cast(hp.stealDone as <signed>integer))
4797 end AS suc_steal
4798 ,100.0*sum(cast(hp.street1Seen as <signed>integer))/count(1) AS saw_f
4799 ,100.0*sum(cast(hp.sawShowdown as <signed>integer))/count(1) AS sawsd
4800 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4801 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4802 end AS wmsf
4803 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4804 else 100.0*sum(cast(hp.sawShowdown as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4805 end AS wtsdwsf
4806 ,case when sum(cast(hp.sawShowdown as <signed>integer)) = 0 then -999
4807 else 100.0*sum(cast(hp.wonAtSD as <signed>integer))/sum(cast(hp.sawShowdown as <signed>integer))
4808 end AS wmsd
4809 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4810 else 100.0*sum(cast(hp.street1Aggr as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4811 end AS flafq
4812 ,case when sum(cast(hp.street2Seen as <signed>integer)) = 0 then -999
4813 else 100.0*sum(cast(hp.street2Aggr as <signed>integer))/sum(cast(hp.street2Seen as <signed>integer))
4814 end AS tuafq
4815 ,case when sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
4816 else 100.0*sum(cast(hp.street3Aggr as <signed>integer))/sum(cast(hp.street3Seen as <signed>integer))
4817 end AS rvafq
4818 ,case when sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
4819 else 100.0*(sum(cast(hp.street1Aggr as <signed>integer))+sum(cast(hp.street2Aggr as <signed>integer))+sum(cast(hp.street3Aggr as <signed>integer)))
4820 /(sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)))
4821 end AS pofafq
4822 ,case when sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer)) = 0 then -999
4823 else (sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer)))
4824 /(0.0+sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer)))
4825 end AS aggfac
4826 ,case when
4827 sum(cast(hp.foldToOtherRaisedStreet1 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet2 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet3 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet4 as <signed>integer))+
4828 sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer))+
4829 sum(cast(hp.street1Aggr as <signed>integer))+ sum(cast(hp.street2Aggr as <signed>integer))+ sum(cast(hp.street3Aggr as <signed>integer))+ sum(cast(hp.street4Aggr as <signed>integer))
4830 = 0 then -999
4831 else
4832 100.0*(sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer)))
4833 / ((sum(cast(hp.foldToOtherRaisedStreet1 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet2 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet3 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet4 as <signed>integer))) +
4834 (sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer))) +
4835 (sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer))) )
4836 end AS aggfrq
4837 ,case when
4838 sum(cast(hp.street1CBChance as <signed>integer))+
4839 sum(cast(hp.street2CBChance as <signed>integer))+
4840 sum(cast(hp.street3CBChance as <signed>integer))+
4841 sum(cast(hp.street4CBChance as <signed>integer)) = 0 then -999
4842 else
4843 100.0*(sum(cast(hp.street1CBDone as <signed>integer)) + sum(cast(hp.street2CBDone as <signed>integer)) + sum(cast(hp.street3CBDone as <signed>integer)) + sum(cast(hp.street4CBDone as <signed>integer)))
4844 / (sum(cast(hp.street1CBChance as <signed>integer))+ sum(cast(hp.street2CBChance as <signed>integer))+ sum(cast(hp.street3CBChance as <signed>integer))+ sum(cast(hp.street4CBChance as <signed>integer)))
4845 end AS conbet
4846 ,sum(hp.totalProfit)/100.0 AS net
4847 ,sum(hp.rake)/100.0 AS rake
4848 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100
4849 ,avg(hp.totalProfit)/100.0 AS profitperhand
4850 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr
4851 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr
4852 ,avg(h.seats+0.0) AS avgseats
4853 ,variance(hp.totalProfit/100.0) AS variance
4854 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev
4855 from HandsPlayers hp
4856 inner join Hands h on (h.id = hp.handId)
4857 inner join Gametypes gt on (gt.Id = h.gametypeId)
4858 inner join Sites s on (s.Id = gt.siteId)
4859 inner join Players p on (p.Id = hp.playerId)
4860 where hp.playerId in <player_test>
4861 <game_test>
4862 <site_test>
4863 <currency_test>
4864 /*and hp.tourneysPlayersId IS NULL*/
4865 and h.seats <seats_test>
4866 <flagtest>
4867 <cardstest>
4868 <gtbigBlind_test>
4869 and to_char(h.startTime, 'YYYY-MM-DD HH24:MI:SS') <datestest>
4870 group by hgametypeId
4871 ,pname
4872 ,gt.base
4873 ,gt.category
4874 ,gt.ante
4875 ,gt.currency
4876 <groupbyseats>
4877 ,plposition
4878 ,upper(gt.limitType)
4879 ,gt.fast
4880 ,s.name
4881 having 1 = 1 <havingclause>
4882 order by pname
4883 ,gt.base
4884 ,gt.category
4885 <orderbyseats>
4886 ,case <position> when 'B' then 'B'
4887 when 'S' then 'S'
4888 when '0' then 'Y'
4889 else 'Z'||<position>
4890 end
4891 <orderbyhgametypeId>
4892 ,upper(gt.limitType) desc
4893 ,maxbigblind desc
4894 ,gt.fast
4895 ,s.name
4896 """
4897 elif db_server == 'sqlite':
4898 self.query['playerDetailedStats'] = """
4899 select <hgametypeId> AS hgametypeid
4900 ,<playerName> AS pname
4901 ,gt.base
4902 ,gt.category AS category
4903 ,upper(gt.limitType) AS limittype
4904 ,s.name AS name
4905 ,min(gt.bigBlind) AS minbigblind
4906 ,max(gt.bigBlind) AS maxbigblind
4907 ,gt.ante AS ante
4908 ,gt.currency AS currency
4909 /*,<hcgametypeId> AS gtid*/
4910 ,<position> AS plposition
4911 ,gt.fast AS fast
4912 ,count(1) AS n
4913 ,case when sum(cast(hp.street0VPIChance as <signed>integer)) = 0 then -999
4914 else 100.0*sum(cast(hp.street0VPI as <signed>integer))/sum(cast(hp.street0VPIChance as <signed>integer))
4915 end AS vpip
4916 ,case when sum(cast(hp.street0AggrChance as <signed>integer)) = 0 then -999
4917 else 100.0*sum(cast(hp.street0Aggr as <signed>integer))/sum(cast(hp.street0AggrChance as <signed>integer))
4918 end AS pfr
4919 ,case when sum(cast(hp.street0CalledRaiseChance as <signed>integer)) = 0 then -999
4920 else 100.0*sum(cast(hp.street0CalledRaiseDone as <signed>integer))/sum(cast(hp.street0CalledRaiseChance as <signed>integer))
4921 end AS car0
4922 ,case when sum(cast(hp.street0_3Bchance as <signed>integer)) = 0 then -999
4923 else 100.0*sum(cast(hp.street0_3Bdone as <signed>integer))/sum(cast(hp.street0_3Bchance as <signed>integer))
4924 end AS pf3
4925 ,case when sum(cast(hp.street0_4Bchance as <signed>integer)) = 0 then -999
4926 else 100.0*sum(cast(hp.street0_4Bdone as <signed>integer))/sum(cast(hp.street0_4Bchance as <signed>integer))
4927 end AS pf4
4928 ,case when sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) = 0 then -999
4929 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo3Bchance as <signed>integer))
4930 end AS pff3
4931 ,case when sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) = 0 then -999
4932 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo4Bchance as <signed>integer))
4933 end AS pff4
4934 ,case when sum(cast(hp.raiseFirstInChance as <signed>integer)) = 0 then -999
4935 else 100.0 * sum(cast(hp.raisedFirstIn as <signed>integer)) /
4936 sum(cast(hp.raiseFirstInChance as <signed>integer))
4937 end AS rfi
4938 ,case when sum(cast(hp.stealChance as <signed>integer)) = 0 then -999
4939 else 100.0 * sum(cast(hp.stealDone as <signed>integer)) /
4940 sum(cast(hp.stealChance as <signed>integer))
4941 end AS steals
4942 ,case when sum(cast(hp.stealDone as <signed>integer)) = 0 then -999
4943 else 100.0 * sum(cast(hp.success_Steal as <signed>integer)) /
4944 sum(cast(hp.stealDone as <signed>integer))
4945 end AS suc_steal
4946 ,100.0*sum(cast(hp.street1Seen as <signed>integer))/count(1) AS saw_f
4947 ,100.0*sum(cast(hp.sawShowdown as <signed>integer))/count(1) AS sawsd
4948 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4949 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4950 end AS wmsf
4951 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4952 else 100.0*sum(cast(hp.sawShowdown as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4953 end AS wtsdwsf
4954 ,case when sum(cast(hp.sawShowdown as <signed>integer)) = 0 then -999
4955 else 100.0*sum(cast(hp.wonAtSD as <signed>integer))/sum(cast(hp.sawShowdown as <signed>integer))
4956 end AS wmsd
4957 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999
4958 else 100.0*sum(cast(hp.street1Aggr as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer))
4959 end AS flafq
4960 ,case when sum(cast(hp.street2Seen as <signed>integer)) = 0 then -999
4961 else 100.0*sum(cast(hp.street2Aggr as <signed>integer))/sum(cast(hp.street2Seen as <signed>integer))
4962 end AS tuafq
4963 ,case when sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
4964 else 100.0*sum(cast(hp.street3Aggr as <signed>integer))/sum(cast(hp.street3Seen as <signed>integer))
4965 end AS rvafq
4966 ,case when sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999
4967 else 100.0*(sum(cast(hp.street1Aggr as <signed>integer))+sum(cast(hp.street2Aggr as <signed>integer))+sum(cast(hp.street3Aggr as <signed>integer)))
4968 /(sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer)))
4969 end AS pofafq
4970 ,case when sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer)) = 0 then -999
4971 else (sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer)))
4972 /(0.0+sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer)))
4973 end AS aggfac
4974 ,100.0*(sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer)))
4975 / ((sum(cast(hp.foldToOtherRaisedStreet1 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet2 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet3 as <signed>integer))+ sum(cast(hp.foldToOtherRaisedStreet4 as <signed>integer))) +
4976 (sum(cast(hp.street1Calls as <signed>integer))+ sum(cast(hp.street2Calls as <signed>integer))+ sum(cast(hp.street3Calls as <signed>integer))+ sum(cast(hp.street4Calls as <signed>integer))) +
4977 (sum(cast(hp.street1Aggr as <signed>integer)) + sum(cast(hp.street2Aggr as <signed>integer)) + sum(cast(hp.street3Aggr as <signed>integer)) + sum(cast(hp.street4Aggr as <signed>integer))) )
4978 AS aggfrq
4979 ,100.0*(sum(cast(hp.street1CBDone as <signed>integer)) + sum(cast(hp.street2CBDone as <signed>integer)) + sum(cast(hp.street3CBDone as <signed>integer)) + sum(cast(hp.street4CBDone as <signed>integer)))
4980 / (sum(cast(hp.street1CBChance as <signed>integer))+ sum(cast(hp.street2CBChance as <signed>integer))+ sum(cast(hp.street3CBChance as <signed>integer))+ sum(cast(hp.street4CBChance as <signed>integer)))
4981 AS conbet
4982 ,sum(hp.totalProfit)/100.0 AS net
4983 ,sum(hp.rake)/100.0 AS rake
4984 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100
4985 ,avg(hp.totalProfit)/100.0 AS profitperhand
4986 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr
4987 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr
4988 ,avg(h.seats+0.0) AS avgseats
4989 ,variance(hp.totalProfit/100.0) AS variance
4990 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev
4991 from HandsPlayers hp
4992 inner join Hands h on (h.id = hp.handId)
4993 inner join Gametypes gt on (gt.Id = h.gametypeId)
4994 inner join Sites s on (s.Id = gt.siteId)
4995 inner join Players p on (p.Id = hp.playerId)
4996 where hp.playerId in <player_test>
4997 <game_test>
4998 <site_test>
4999 <currency_test>
5000 /*and hp.tourneysPlayersId IS NULL*/
5001 and h.seats <seats_test>
5002 <flagtest>
5003 <cardstest>
5004 <gtbigBlind_test>
5005 and datetime(h.startTime) <datestest>
5006 group by hgametypeId
5007 ,hp.playerId
5008 ,gt.base
5009 ,gt.category
5010 <groupbyseats>
5011 ,plposition
5012 ,upper(gt.limitType)
5013 ,gt.fast
5014 ,s.name
5015 having 1 = 1 <havingclause>
5016 order by hp.playerId
5017 ,gt.base
5018 ,gt.category
5019 <orderbyseats>
5020 ,case <position> when 'B' then 'B'
5021 when 'S' then 'S'
5022 when '0' then 'Y'
5023 else 'Z'||<position>
5024 end
5025 <orderbyhgametypeId>
5026 ,upper(gt.limitType) desc
5027 ,max(gt.bigBlind) desc
5028 ,gt.fast
5029 ,s.name
5030 """
5032 #FIXME: 3/4bet and foldTo don't added four tournaments yet
5033 if db_server == 'mysql':
5034 self.query['tourneyPlayerDetailedStats'] = """
5035 select s.name AS siteName
5036 ,tt.currency AS currency
5037 ,(CASE
5038 WHEN tt.currency = 'play' THEN tt.buyIn
5039 ELSE tt.buyIn/100.0
5040 END) AS buyIn
5041 ,tt.fee/100.0 AS fee
5042 ,tt.category AS category
5043 ,tt.limitType AS limitType
5044 ,tt.speed AS speed
5045 ,tt.maxSeats AS maxSeats
5046 ,tt.knockout AS knockout
5047 ,tt.reEntry AS reEntry
5048 ,p.name AS playerName
5049 ,COUNT(1) AS tourneyCount
5050 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS unknownRank
5051 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS SIGNED)/CAST(COUNT(1) AS SIGNED))*100 AS itm
5052 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS _1st
5053 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS _2nd
5054 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS _3rd
5055 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS won
5056 ,SUM(CASE
5057 WHEN tt.currency = 'play' THEN tt.buyIn
5058 ELSE (tt.buyIn+tt.fee)/100.0
5059 END) AS spent
5060 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS net
5061 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS SIGNED)/
5062 CAST(SUM(tt.buyin+tt.fee) AS SIGNED))* 100.0 AS roi
5063 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-(tt.buyin+tt.fee))/100.0/(COUNT(1)-SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END)) AS profitPerTourney
5064 from TourneysPlayers tp
5065 inner join Tourneys t on (t.id = tp.tourneyId)
5066 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId)
5067 inner join Sites s on (s.Id = tt.siteId)
5068 inner join Players p on (p.Id = tp.playerId)
5069 where tp.playerId in <nametest> <sitetest>
5070 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
5071 OR t.startTime is NULL)
5072 group by tourneyTypeId, playerName
5073 order by tourneyTypeId
5074 ,playerName
5075 ,siteName"""
5076 elif db_server == 'postgresql':
5077 # sc: itm and profitPerTourney changed to "ELSE 0" to avoid divide by zero error as temp fix
5078 # proper fix should use coalesce() or case ... when ... to work in all circumstances
5079 self.query['tourneyPlayerDetailedStats'] = """
5080 select s.name AS "siteName"
5081 ,tt.currency AS "currency"
5082 ,(CASE
5083 WHEN tt.currency = 'play' THEN tt.buyIn
5084 ELSE tt.buyIn/100.0
5085 END) AS "buyIn"
5086 ,tt.fee/100.0 AS "fee"
5087 ,tt.category AS "category"
5088 ,tt.limitType AS "limitType"
5089 ,tt.speed AS "speed"
5090 ,tt.maxSeats AS "maxSeats"
5091 ,tt.knockout AS "knockout"
5092 ,tt.reEntry AS "reEntry"
5093 ,p.name AS "playerName"
5094 ,COUNT(1) AS "tourneyCount"
5095 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS "unknownRank"
5096 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS BIGINT)/CAST(COUNT(1) AS BIGINT))*100 AS itm
5097 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS "_1st"
5098 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS "_2nd"
5099 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS "_3rd"
5100 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS "won"
5101 ,SUM(CASE
5102 WHEN tt.currency = 'play' THEN tt.buyIn
5103 ELSE (tt.buyIn+tt.fee)/100.0
5104 END) AS "spent"
5105 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS "net"
5106 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS BIGINT)/
5107 CAST(SUM(tt.buyin+tt.fee) AS BIGINT))* 100.0 AS "roi"
5108 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-(tt.buyin+tt.fee))/100.0
5109 /(COUNT(1)-SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 0 END)) AS "profitPerTourney"
5110 from TourneysPlayers tp
5111 inner join Tourneys t on (t.id = tp.tourneyId)
5112 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId)
5113 inner join Sites s on (s.Id = tt.siteId)
5114 inner join Players p on (p.Id = tp.playerId)
5115 where tp.playerId in <nametest> <sitetest>
5116 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
5117 OR t.startTime is NULL)
5118 group by t.tourneyTypeId, s.name, p.name, tt.currency, tt.buyin, tt.fee
5119 , tt.category, tt.limitType, tt.speed
5120 order by t.tourneyTypeId
5121 ,p.name
5122 ,s.name"""
5123 elif db_server == 'sqlite':
5124 self.query['tourneyPlayerDetailedStats'] = """
5125 select s.name AS siteName
5126 ,tt.currency AS currency
5127 ,(CASE
5128 WHEN tt.currency = 'play' THEN tt.buyIn
5129 ELSE tt.buyIn/100.0
5130 END) AS buyIn
5131 ,tt.fee/100.0 AS fee
5132 ,tt.category AS category
5133 ,tt.limitType AS limitType
5134 ,tt.speed AS speed
5135 ,tt.maxSeats AS maxSeats
5136 ,tt.knockout AS knockout
5137 ,tt.reEntry AS reEntry
5138 ,p.name AS playerName
5139 ,COUNT(1) AS tourneyCount
5140 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS unknownRank
5141 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS REAL)/CAST(COUNT(1) AS REAL))*100 AS itm
5142 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS _1st
5143 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS _2nd
5144 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS _3rd
5145 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS won
5146 ,SUM(CASE
5147 WHEN tt.currency = 'play' THEN tt.buyIn
5148 ELSE (tt.buyIn+tt.fee)/100.0
5149 END) AS spent
5150 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS net
5151 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS REAL)/
5152 CAST(SUM(tt.buyin+tt.fee) AS REAL))* 100.0 AS roi
5153 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-(tt.buyin+tt.fee))/100.0/(COUNT(1)-SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END)) AS profitPerTourney
5154 from TourneysPlayers tp
5155 inner join Tourneys t on (t.id = tp.tourneyId)
5156 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId)
5157 inner join Sites s on (s.Id = tt.siteId)
5158 inner join Players p on (p.Id = tp.playerId)
5159 where tp.playerId in <nametest> <sitetest>
5160 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
5161 OR t.startTime is NULL)
5162 group by tourneyTypeId, playerName
5163 order by tourneyTypeId
5164 ,playerName
5165 ,siteName"""
5167 if db_server == 'mysql':
5168 self.query['playerStats'] = """
5169 SELECT
5170 concat(upper(stats.limitType), ' '
5171 ,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' '
5172 ,stats.name, ' '
5173 ,cast(stats.bigBlindDesc as char)
5174 ) AS Game
5175 ,stats.n
5176 ,stats.vpip
5177 ,stats.pfr
5178 ,stats.pf3
5179 ,stats.pf4
5180 ,stats.pff3
5181 ,stats.pff4
5182 ,stats.steals
5183 ,stats.saw_f
5184 ,stats.sawsd
5185 ,stats.wtsdwsf
5186 ,stats.wmsd
5187 ,stats.FlAFq
5188 ,stats.TuAFq
5189 ,stats.RvAFq
5190 ,stats.PoFAFq
5191 ,stats.Net
5192 ,stats.BBper100
5193 ,stats.Profitperhand
5194 ,case when hprof2.variance = -999 then '-'
5195 else format(hprof2.variance, 2)
5196 end AS Variance
5197 ,case when hprof2.stddev = -999 then '-'
5198 else format(hprof2.stddev, 2)
5199 end AS Stddev
5200 ,stats.AvgSeats
5201 FROM
5202 (select /* stats from hudcache */
5203 gt.base
5204 ,gt.category
5205 ,upper(gt.limitType) as limitType
5206 ,s.name
5207 ,<selectgt.bigBlind> AS bigBlindDesc
5208 ,<hcgametypeId> AS gtId
5209 ,sum(n) AS n
5210 ,case when sum(street0VPIChance) = 0 then '0'
5211 else format(100.0*sum(street0VPI)/sum(street0VPIChance),1)
5212 end AS vpip
5213 ,case when sum(street0AggrChance) = 0 then '0'
5214 else format(100.0*sum(street0Aggr)/sum(street0AggrChance),1)
5215 end AS pfr
5216 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5217 else format(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1)
5218 end AS car0
5219 ,case when sum(street0_3Bchance) = 0 then '0'
5220 else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1)
5221 end AS pf3
5222 ,case when sum(street0_4Bchance) = 0 then '0'
5223 else format(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1)
5224 end AS pf4
5225 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5226 else format(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1)
5227 end AS pff3
5228 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5229 else format(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1)
5230 end AS pff4
5231 ,case when sum(raiseFirstInChance) = 0 then '-'
5232 else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1)
5233 end AS steals
5234 ,format(100.0*sum(street1Seen)/sum(n),1) AS saw_f
5235 ,format(100.0*sum(sawShowdown)/sum(n),1) AS sawsd
5236 ,case when sum(street1Seen) = 0 then '-'
5237 else format(100.0*sum(sawShowdown)/sum(street1Seen),1)
5238 end AS wtsdwsf
5239 ,case when sum(sawShowdown) = 0 then '-'
5240 else format(100.0*sum(wonAtSD)/sum(sawShowdown),1)
5241 end AS wmsd
5242 ,case when sum(street1Seen) = 0 then '-'
5243 else format(100.0*sum(street1Aggr)/sum(street1Seen),1)
5244 end AS FlAFq
5245 ,case when sum(street2Seen) = 0 then '-'
5246 else format(100.0*sum(street2Aggr)/sum(street2Seen),1)
5247 end AS TuAFq
5248 ,case when sum(street3Seen) = 0 then '-'
5249 else format(100.0*sum(street3Aggr)/sum(street3Seen),1)
5250 end AS RvAFq
5251 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5252 else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5253 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
5254 end AS PoFAFq
5255 ,format(sum(totalProfit)/100.0,2) AS Net
5256 ,format((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2)
5257 AS BBper100
5258 ,format( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand
5259 ,format( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats
5260 from Gametypes gt
5261 inner join Sites s on s.Id = gt.siteId
5262 inner join HudCache hc on hc.gametypeId = gt.Id
5263 where hc.playerId in <player_test>
5264 <gtbigBlind_test>
5265 and hc.seats <seats_test>
5266 and concat( '20', substring(hc.styleKey,2,2), '-', substring(hc.styleKey,4,2), '-'
5267 , substring(hc.styleKey,6,2) ) <datestest>
5268 group by gt.base
5269 ,gt.category
5270 ,upper(gt.limitType)
5271 ,s.name
5272 <groupbygt.bigBlind>
5273 ,gtId
5274 ) stats
5275 inner join
5276 ( select # profit from handsplayers/handsactions
5277 hprof.gtId, sum(hprof.profit) sum_profit,
5278 avg(hprof.profit/100.0) profitperhand,
5279 case when hprof.gtId = -1 then -999
5280 else variance(hprof.profit/100.0)
5281 end as variance
5282 ,sqrt(variance(hprof.profit/100.0)) AS stddev
5283 from
5284 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit
5285 from HandsPlayers hp
5286 inner join Hands h ON h.id = hp.handId
5287 where hp.playerId in <player_test>
5288 and hp.tourneysPlayersId IS NULL
5289 and date_format(h.startTime, '%Y-%m-%d') <datestest>
5290 group by hp.handId, gtId, hp.totalProfit
5291 ) hprof
5292 group by hprof.gtId
5293 ) hprof2
5294 on hprof2.gtId = stats.gtId
5295 order by stats.category, stats.limittype, stats.bigBlindDesc desc <orderbyseats>"""
5296 elif db_server == 'sqlite':
5297 self.query['playerStats'] = """
5298 SELECT
5299 upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' ' ||
5300 stats.name || ' ' ||
5301 cast(stats.bigBlindDesc as char) || ' ' || stats.maxSeats || ' seat' AS Game
5302 ,stats.n,stats.vpip,stats.pfr,stats.pf3,stats.pf4,stats.pff3,stats.pff4
5303 ,stats.steals,stats.saw_f,stats.sawsd,stats.wtsdwsf,stats.wmsd,stats.FlAFq
5304 ,stats.TuAFq,stats.RvAFq,stats.PoFAFq,stats.Net,stats.BBper100,stats.Profitperhand
5305 ,case when hprof2.variance = -999 then '-' else round(hprof2.variance, 2)
5306 end AS Variance
5307 ,case when hprof2.stddev = -999 then '-' else round(hprof2.stddev, 2)
5308 end AS Stddev
5309 ,stats.AvgSeats
5310 FROM
5311 (select /* stats from hudcache */
5312 gt.base
5313 ,gt.category,maxSeats,gt.bigBlind,gt.currency
5314 ,upper(gt.limitType) AS limitType
5315 ,s.name
5316 ,<selectgt.bigBlind> AS bigBlindDesc
5317 ,<hcgametypeId> AS gtId
5318 ,sum(n) AS n
5319 ,case when sum(street0VPIChance) = 0 then '0'
5320 else round(100.0*sum(street0VPI)/sum(street0VPIChance),1)
5321 end AS vpip
5322 ,case when sum(street0AggrChance) = 0 then '0'
5323 else round(100.0*sum(street0Aggr)/sum(street0AggrChance),1)
5324 end AS pfr
5325 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5326 else round(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1)
5327 end AS car0
5328 ,case when sum(street0_3Bchance) = 0 then '0'
5329 else round(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1)
5330 end AS pf3
5331 ,case when sum(street0_4Bchance) = 0 then '0'
5332 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1)
5333 end AS pf4
5334 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5335 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1)
5336 end AS pff3
5337 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5338 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1)
5339 end AS pff4
5340 ,case when sum(raiseFirstInChance) = 0 then '-'
5341 else round(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1)
5342 end AS steals
5343 ,round(100.0*sum(street1Seen)/sum(n),1) AS saw_f
5344 ,round(100.0*sum(sawShowdown)/sum(n),1) AS sawsd
5345 ,case when sum(street1Seen) = 0 then '-'
5346 else round(100.0*sum(sawShowdown)/sum(street1Seen),1)
5347 end AS wtsdwsf
5348 ,case when sum(sawShowdown) = 0 then '-'
5349 else round(100.0*sum(wonAtSD)/sum(sawShowdown),1)
5350 end AS wmsd
5351 ,case when sum(street1Seen) = 0 then '-'
5352 else round(100.0*sum(street1Aggr)/sum(street1Seen),1)
5353 end AS FlAFq
5354 ,case when sum(street2Seen) = 0 then '-'
5355 else round(100.0*sum(street2Aggr)/sum(street2Seen),1)
5356 end AS TuAFq
5357 ,case when sum(street3Seen) = 0 then '-'
5358 else round(100.0*sum(street3Aggr)/sum(street3Seen),1)
5359 end AS RvAFq
5360 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5361 else round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5362 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
5363 end AS PoFAFq
5364 ,round(sum(totalProfit)/100.0,2) AS Net
5365 ,round((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2)
5366 AS BBper100
5367 ,round( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand
5368 ,round( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats
5369 from Gametypes gt
5370 inner join Sites s on s.Id = gt.siteId
5371 inner join HudCache hc on hc.gametypeId = gt.Id
5372 where hc.playerId in <player_test>
5373 <gtbigBlind_test>
5374 and hc.seats <seats_test>
5375 and '20' || substr(hc.styleKey,2,2) || '-' || substr(hc.styleKey,4,2) || '-' ||
5376 substr(hc.styleKey,6,2) <datestest>
5377 group by gt.base,gt.category,upper(gt.limitType),s.name <groupbygt.bigBlind>,gtId
5378 ) stats
5379 inner join
5380 ( select /* profit from handsplayers/handsactions */
5381 hprof.gtId, sum(hprof.profit) sum_profit,
5382 avg(hprof.profit/100.0) profitperhand,
5383 case when hprof.gtId = -1 then -999
5384 else variance(hprof.profit/100.0)
5385 end as variance
5386 ,case when hprof.gtId = -1 then -999
5387 else sqrt(variance(hprof.profit/100.0))
5388 end as stddev
5389 from
5390 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit
5391 from HandsPlayers hp
5392 inner join Hands h ON h.id = hp.handId
5393 where hp.playerId in <player_test>
5394 and hp.tourneysPlayersId IS NULL
5395 and datetime(h.startTime) <datestest>
5396 group by hp.handId, gtId, hp.totalProfit
5397 ) hprof
5398 group by hprof.gtId
5399 ) hprof2
5400 on hprof2.gtId = stats.gtId
5401 order by stats.category, stats.bigBlind, stats.limittype, stats.currency, stats.maxSeats <orderbyseats>"""
5402 else: # assume postgres
5403 self.query['playerStats'] = """
5404 SELECT upper(stats.limitType) || ' '
5405 || initcap(stats.category) || ' '
5406 || stats.name || ' '
5407 || stats.bigBlindDesc AS Game
5408 ,stats.n
5409 ,stats.vpip
5410 ,stats.pfr
5411 ,stats.pf3
5412 ,stats.pf4
5413 ,stats.pff3
5414 ,stats.pff4
5415 ,stats.steals
5416 ,stats.saw_f
5417 ,stats.sawsd
5418 ,stats.wtsdwsf
5419 ,stats.wmsd
5420 ,stats.FlAFq
5421 ,stats.TuAFq
5422 ,stats.RvAFq
5423 ,stats.PoFAFq
5424 ,stats.Net
5425 ,stats.BBper100
5426 ,stats.Profitperhand
5427 ,case when hprof2.variance = -999 then '-'
5428 else to_char(hprof2.variance, '0D00')
5429 end AS Variance
5430 ,case when hprof2.stddev = -999 then '-'
5431 else to_char(hprof2.stddev, '0D00')
5432 end AS Stddev
5433 ,AvgSeats
5434 FROM
5435 (select gt.base
5436 ,gt.category
5437 ,upper(gt.limitType) AS limitType
5438 ,s.name
5439 ,<selectgt.bigBlind> AS bigBlindDesc
5440 ,<hcgametypeId> AS gtId
5441 ,sum(n) AS n
5442 ,case when sum(street0VPIChance) = 0 then '0'
5443 else to_char(100.0*sum(street0VPI)/sum(street0VPIChance),'990D0')
5444 end AS vpip
5445 ,case when sum(street0AggrChance) = 0 then '0'
5446 else to_char(100.0*sum(street0Aggr)/sum(street0AggrChance),'90D0')
5447 end AS pfr
5448 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5449 else to_char(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),'90D0')
5450 end AS car0
5451 ,case when sum(street0_3Bchance) = 0 then '0'
5452 else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0')
5453 end AS pf3
5454 ,case when sum(street0_4Bchance) = 0 then '0'
5455 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1)
5456 end AS pf4
5457 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5458 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1)
5459 end AS pff3
5460 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5461 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1)
5462 end AS pff4
5463 ,case when sum(raiseFirstInChance) = 0 then '-'
5464 else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0')
5465 end AS steals
5466 ,to_char(100.0*sum(street1Seen)/sum(n),'90D0') AS saw_f
5467 ,to_char(100.0*sum(sawShowdown)/sum(n),'90D0') AS sawsd
5468 ,case when sum(street1Seen) = 0 then '-'
5469 else to_char(100.0*sum(sawShowdown)/sum(street1Seen),'90D0')
5470 end AS wtsdwsf
5471 ,case when sum(sawShowdown) = 0 then '-'
5472 else to_char(100.0*sum(wonAtSD)/sum(sawShowdown),'90D0')
5473 end AS wmsd
5474 ,case when sum(street1Seen) = 0 then '-'
5475 else to_char(100.0*sum(street1Aggr)/sum(street1Seen),'90D0')
5476 end AS FlAFq
5477 ,case when sum(street2Seen) = 0 then '-'
5478 else to_char(100.0*sum(street2Aggr)/sum(street2Seen),'90D0')
5479 end AS TuAFq
5480 ,case when sum(street3Seen) = 0 then '-'
5481 else to_char(100.0*sum(street3Aggr)/sum(street3Seen),'90D0')
5482 end AS RvAFq
5483 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5484 else to_char(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5485 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),'90D0')
5486 end AS PoFAFq
5487 ,round(sum(totalProfit)/100.0,2) AS Net
5488 ,to_char((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0), '990D00')
5489 AS BBper100
5490 ,to_char(sum(totalProfit/100.0) / (sum(n)+0.0), '990D0000') AS Profitperhand
5491 ,to_char(sum(seats*n)/(sum(n)+0.0),'90D00') AS AvgSeats
5492 from Gametypes gt
5493 inner join Sites s on s.Id = gt.siteId
5494 inner join HudCache hc on hc.gametypeId = gt.Id
5495 where hc.playerId in <player_test>
5496 <gtbigBlind_test>
5497 and hc.seats <seats_test>
5498 and '20' || SUBSTR(hc.styleKey,2,2) || '-' || SUBSTR(hc.styleKey,4,2) || '-'
5499 || SUBSTR(hc.styleKey,6,2) <datestest>
5500 group by gt.base
5501 ,gt.category
5502 ,upper(gt.limitType)
5503 ,s.name
5504 <groupbygt.bigBlind>
5505 ,gtId
5506 ) stats
5507 inner join
5508 ( select
5509 hprof.gtId, sum(hprof.profit) AS sum_profit,
5510 avg(hprof.profit/100.0) AS profitperhand,
5511 case when hprof.gtId = -1 then -999
5512 else variance(hprof.profit/100.0)
5513 end as variance
5514 ,case when hprof.gtId = -1 then -999
5515 else sqrt(variance(hprof.profit/100.0))
5516 end as stddev
5517 from
5518 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit
5519 from HandsPlayers hp
5520 inner join Hands h ON (h.id = hp.handId)
5521 where hp.playerId in <player_test>
5522 and hp.tourneysPlayersId IS NULL
5523 and to_char(h.startTime, 'YYYY-MM-DD') <datestest>
5524 group by hp.handId, gtId, hp.totalProfit
5525 ) hprof
5526 group by hprof.gtId
5527 ) hprof2
5528 on hprof2.gtId = stats.gtId
5529 order by stats.base, stats.limittype, stats.bigBlindDesc desc <orderbyseats>"""
5531 if db_server == 'mysql':
5532 self.query['playerStatsByPosition'] = """
5533 SELECT
5534 concat(upper(stats.limitType), ' '
5535 ,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' '
5536 ,stats.name, ' '
5537 ,cast(stats.bigBlindDesc as char)
5538 ) AS Game
5539 ,case when stats.PlPosition = -2 then 'BB'
5540 when stats.PlPosition = -1 then 'SB'
5541 when stats.PlPosition = 0 then 'Btn'
5542 when stats.PlPosition = 1 then 'CO'
5543 when stats.PlPosition = 2 then 'MP'
5544 when stats.PlPosition = 5 then 'EP'
5545 else 'xx'
5546 end AS PlPosition
5547 ,stats.n
5548 ,stats.vpip
5549 ,stats.pfr
5550 ,stats.car0
5551 ,stats.pf3
5552 ,stats.pf4
5553 ,stats.pff3
5554 ,stats.pff4
5555 ,stats.steals
5556 ,stats.saw_f
5557 ,stats.sawsd
5558 ,stats.wtsdwsf
5559 ,stats.wmsd
5560 ,stats.FlAFq
5561 ,stats.TuAFq
5562 ,stats.RvAFq
5563 ,stats.PoFAFq
5564 ,stats.Net
5565 ,stats.BBper100
5566 ,stats.Profitperhand
5567 ,case when hprof2.variance = -999 then '-'
5568 else format(hprof2.variance, 2)
5569 end AS Variance
5570 ,case when hprof2.stddev = -999 then '-'
5571 else format(hprof2.stddev, 2)
5572 end AS Stddev
5573 ,stats.AvgSeats
5574 FROM
5575 (select /* stats from hudcache */
5576 gt.base
5577 ,gt.category
5578 ,upper(gt.limitType) AS limitType
5579 ,s.name
5580 ,<selectgt.bigBlind> AS bigBlindDesc
5581 ,<hcgametypeId> AS gtId
5582 ,case when hc.position = 'B' then -2
5583 when hc.position = 'S' then -1
5584 when hc.position = 'D' then 0
5585 when hc.position = 'C' then 1
5586 when hc.position = 'M' then 2
5587 when hc.position = 'E' then 5
5588 else 9
5589 end as PlPosition
5590 ,sum(n) AS n
5591 ,case when sum(street0VPIChance) = 0 then '0'
5592 else format(100.0*sum(street0VPI)/sum(street0VPIChance),1)
5593 end AS vpip
5594 ,case when sum(street0AggrChance) = 0 then '0'
5595 else format(100.0*sum(street0Aggr)/sum(street0AggrChance),1)
5596 end AS pfr
5597 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5598 else format(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1)
5599 end AS car0
5600 ,case when sum(street0_3Bchance) = 0 then '0'
5601 else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1)
5602 end AS pf3
5603 ,case when sum(street0_4Bchance) = 0 then '0'
5604 else format(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1)
5605 end AS pf4
5606 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5607 else format(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1)
5608 end AS pff3
5609 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5610 else format(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1)
5611 end AS pff4
5612 ,case when sum(raiseFirstInChance) = 0 then '-'
5613 else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1)
5614 end AS steals
5615 ,format(100.0*sum(street1Seen)/sum(n),1) AS saw_f
5616 ,format(100.0*sum(sawShowdown)/sum(n),1) AS sawsd
5617 ,case when sum(street1Seen) = 0 then '-'
5618 else format(100.0*sum(sawShowdown)/sum(street1Seen),1)
5619 end AS wtsdwsf
5620 ,case when sum(sawShowdown) = 0 then '-'
5621 else format(100.0*sum(wonAtSD)/sum(sawShowdown),1)
5622 end AS wmsd
5623 ,case when sum(street1Seen) = 0 then '-'
5624 else format(100.0*sum(street1Aggr)/sum(street1Seen),1)
5625 end AS FlAFq
5626 ,case when sum(street2Seen) = 0 then '-'
5627 else format(100.0*sum(street2Aggr)/sum(street2Seen),1)
5628 end AS TuAFq
5629 ,case when sum(street3Seen) = 0 then '-'
5630 else format(100.0*sum(street3Aggr)/sum(street3Seen),1)
5631 end AS RvAFq
5632 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5633 else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5634 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
5635 end AS PoFAFq
5636 ,format(sum(totalProfit)/100.0,2) AS Net
5637 ,format((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2)
5638 AS BBper100
5639 ,format( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand
5640 ,format( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats
5641 from Gametypes gt
5642 inner join Sites s on s.Id = gt.siteId
5643 inner join HudCache hc on hc.gametypeId = gt.Id
5644 where hc.playerId in <player_test>
5645 <gtbigBlind_test>
5646 and hc.seats <seats_test>
5647 and concat( '20', substring(hc.styleKey,2,2), '-', substring(hc.styleKey,4,2), '-'
5648 , substring(hc.styleKey,6,2) ) <datestest>
5649 group by gt.base
5650 ,gt.category
5651 ,upper(gt.limitType)
5652 ,s.name
5653 <groupbygt.bigBlind>
5654 ,gtId
5655 <groupbyseats>
5656 ,PlPosition
5657 ) stats
5658 inner join
5659 ( select # profit from handsplayers/handsactions
5660 hprof.gtId,
5661 case when hprof.position = 'B' then -2
5662 when hprof.position = 'S' then -1
5663 when hprof.position in ('3','4') then 2
5664 when hprof.position in ('6','7') then 5
5665 else hprof.position
5666 end as PlPosition,
5667 sum(hprof.profit) as sum_profit,
5668 avg(hprof.profit/100.0) as profitperhand,
5669 case when hprof.gtId = -1 then -999
5670 else variance(hprof.profit/100.0)
5671 end as variance
5672 ,case when hprof.gtId = -1 then -999
5673 else sqrt(variance(hprof.profit/100.0))
5674 end as stddev
5675 from
5676 (select hp.handId, <hgametypeId> as gtId, hp.position
5677 , hp.totalProfit as profit
5678 from HandsPlayers hp
5679 inner join Hands h ON (h.id = hp.handId)
5680 where hp.playerId in <player_test>
5681 and hp.tourneysPlayersId IS NULL
5682 and date_format(h.startTime, '%Y-%m-%d') <datestest>
5683 group by hp.handId, gtId, hp.position, hp.totalProfit
5684 ) hprof
5685 group by hprof.gtId, PlPosition
5686 ) hprof2
5687 on ( hprof2.gtId = stats.gtId
5688 and hprof2.PlPosition = stats.PlPosition)
5689 order by stats.category, stats.limitType, stats.bigBlindDesc desc
5690 <orderbyseats>, cast(stats.PlPosition as signed)
5691 """
5692 elif db_server == 'sqlite':
5693 self.query['playerStatsByPosition'] = """
5694 SELECT
5695 upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' ' ||
5696 stats.name || ' ' ||
5697 cast(stats.bigBlindDesc as char) || ' ' || stats.maxSeats || ' seat' AS Game
5698 ,case when stats.PlPosition = -2 then 'BB'
5699 when stats.PlPosition = -1 then 'SB'
5700 when stats.PlPosition = 0 then 'Btn'
5701 when stats.PlPosition = 1 then 'CO'
5702 when stats.PlPosition = 2 then 'MP'
5703 when stats.PlPosition = 5 then 'EP'
5704 else 'xx'
5705 end AS PlPosition
5706 ,stats.n,stats.vpip,stats.pfr,stats.pf3,stats.pf4,stats.pff3,stats.pff4
5707 ,stats.steals,stats.saw_f,stats.sawsd,stats.wtsdwsf,stats.wmsd,stats.FlAFq
5708 ,stats.TuAFq,stats.RvAFq,stats.PoFAFq,stats.Net,stats.BBper100,stats.Profitperhand
5709 ,case when hprof2.variance = -999 then '-'
5710 else round(hprof2.variance, 2)
5711 end AS Variance
5712 ,case when hprof2.variance = -999 then '-'
5713 else round(hprof2.stddev, 2)
5714 end AS Stddev
5715 ,stats.AvgSeats
5716 FROM
5717 (select /* stats from hudcache */
5718 gt.base
5719 ,gt.category,maxSeats,gt.bigBlind,gt.currency
5720 ,upper(gt.limitType) AS limitType
5721 ,s.name
5722 ,<selectgt.bigBlind> AS bigBlindDesc
5723 ,<hcgametypeId> AS gtId
5724 ,case when hc.position = 'B' then -2
5725 when hc.position = 'S' then -1
5726 when hc.position = 'D' then 0
5727 when hc.position = 'C' then 1
5728 when hc.position = 'M' then 2
5729 when hc.position = 'E' then 5
5730 else 9
5731 end AS PlPosition
5732 ,sum(n) AS n
5733 ,case when sum(street0VPIChance) = 0 then '0'
5734 else round(100.0*sum(street0VPI)/sum(street0VPIChance),1)
5735 end AS vpip
5736 ,case when sum(street0AggrChance) = 0 then '0'
5737 else round(100.0*sum(street0Aggr)/sum(street0AggrChance),1)
5738 end AS pfr
5739 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5740 else round(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1)
5741 end AS car0
5742 ,case when sum(street0_3Bchance) = 0 then '0'
5743 else round(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1)
5744 end AS pf3
5745 ,case when sum(street0_4Bchance) = 0 then '0'
5746 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1)
5747 end AS pf4
5748 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5749 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1)
5750 end AS pff3
5751 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5752 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1)
5753 end AS pff4
5754 ,case when sum(raiseFirstInChance) = 0 then '-'
5755 else round(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1)
5756 end AS steals
5757 ,round(100.0*sum(street1Seen)/sum(n),1) AS saw_f
5758 ,round(100.0*sum(sawShowdown)/sum(n),1) AS sawsd
5759 ,case when sum(street1Seen) = 0 then '-'
5760 else round(100.0*sum(sawShowdown)/sum(street1Seen),1)
5761 end AS wtsdwsf
5762 ,case when sum(sawShowdown) = 0 then '-'
5763 else round(100.0*sum(wonAtSD)/sum(sawShowdown),1)
5764 end AS wmsd
5765 ,case when sum(street1Seen) = 0 then '-'
5766 else round(100.0*sum(street1Aggr)/sum(street1Seen),1)
5767 end AS FlAFq
5768 ,case when sum(street2Seen) = 0 then '-'
5769 else round(100.0*sum(street2Aggr)/sum(street2Seen),1)
5770 end AS TuAFq
5771 ,case when sum(street3Seen) = 0 then '-'
5772 else round(100.0*sum(street3Aggr)/sum(street3Seen),1)
5773 end AS RvAFq
5774 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5775 else round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5776 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
5777 end AS PoFAFq
5778 ,round(sum(totalProfit)/100.0,2) AS Net
5779 ,round((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2)
5780 AS BBper100
5781 ,round( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand
5782 ,round( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats
5783 from Gametypes gt
5784 inner join Sites s on s.Id = gt.siteId
5785 inner join HudCache hc on hc.gametypeId = gt.Id
5786 where hc.playerId in <player_test>
5787 <gtbigBlind_test>
5788 and hc.seats <seats_test>
5789 and '20' || substr(hc.styleKey,2,2) || '-' || substr(hc.styleKey,4,2) || '-' ||
5790 substr(hc.styleKey,6,2) <datestest>
5791 group by gt.base,gt.category,upper(gt.limitType),s.name
5792 <groupbygt.bigBlind>,gtId<groupbyseats>,PlPosition
5793 ) stats
5794 inner join
5795 ( select /* profit from handsplayers/handsactions */
5796 hprof.gtId,
5797 cast(case when hprof.position = 'B' then -2
5798 when hprof.position = 'S' then -1
5799 when hprof.position in ('3','4') then 2
5800 when hprof.position in ('6','7') then 5
5801 else hprof.position
5802 end as signed) as PlPosition,
5803 sum(hprof.profit) as sum_profit,
5804 avg(hprof.profit/100.0) as profitperhand,
5805 case when hprof.gtId = -1 then -999
5806 else variance(hprof.profit/100.0)
5807 end as variance
5808 ,case when hprof.gtId = -1 then -999
5809 else sqrt(variance(hprof.profit/100.0))
5810 end as stddev
5811 from
5812 (select hp.handId, <hgametypeId> as gtId, hp.position
5813 , hp.totalProfit as profit
5814 from HandsPlayers hp
5815 inner join Hands h ON (h.id = hp.handId)
5816 where hp.playerId in <player_test>
5817 and hp.tourneysPlayersId IS NULL
5818 and datetime(h.startTime) <datestest>
5819 group by hp.handId, gtId, hp.position, hp.totalProfit
5820 ) hprof
5821 group by hprof.gtId, PlPosition
5822 ) hprof2
5823 on ( hprof2.gtId = stats.gtId
5824 and hprof2.PlPosition = stats.PlPosition)
5825 order by stats.category, stats.bigBlind, stats.limitType, stats.currency, stats.maxSeats <orderbyseats>
5826 ,cast(stats.PlPosition as signed)
5827 """
5828 else: # assume postgresql
5829 self.query['playerStatsByPosition'] = """
5830 select /* stats from hudcache */
5831 upper(stats.limitType) || ' '
5832 || upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' '
5833 || stats.name || ' '
5834 || stats.bigBlindDesc AS Game
5835 ,case when stats.PlPosition = -2 then 'BB'
5836 when stats.PlPosition = -1 then 'SB'
5837 when stats.PlPosition = 0 then 'Btn'
5838 when stats.PlPosition = 1 then 'CO'
5839 when stats.PlPosition = 2 then 'MP'
5840 when stats.PlPosition = 5 then 'EP'
5841 else 'xx'
5842 end AS PlPosition
5843 ,stats.n
5844 ,stats.vpip
5845 ,stats.pfr
5846 ,stats.pf3
5847 ,stats.pf4
5848 ,stats.pff3
5849 ,stats.pff4
5850 ,stats.steals
5851 ,stats.saw_f
5852 ,stats.sawsd
5853 ,stats.wtsdwsf
5854 ,stats.wmsd
5855 ,stats.FlAFq
5856 ,stats.TuAFq
5857 ,stats.RvAFq
5858 ,stats.PoFAFq
5859 ,stats.Net
5860 ,stats.BBper100
5861 ,stats.Profitperhand
5862 ,case when hprof2.variance = -999 then '-'
5863 else to_char(hprof2.variance, '0D00')
5864 end AS Variance
5865 ,case when hprof2.stddev = -999 then '-'
5866 else to_char(hprof2.stddev, '0D00')
5867 end AS Stddev
5868 ,stats.AvgSeats
5869 FROM
5870 (select /* stats from hudcache */
5871 gt.base
5872 ,gt.category
5873 ,upper(gt.limitType) AS limitType
5874 ,s.name
5875 ,<selectgt.bigBlind> AS bigBlindDesc
5876 ,<hcgametypeId> AS gtId
5877 ,case when hc.position = 'B' then -2
5878 when hc.position = 'S' then -1
5879 when hc.position = 'D' then 0
5880 when hc.position = 'C' then 1
5881 when hc.position = 'M' then 2
5882 when hc.position = 'E' then 5
5883 else 9
5884 end AS PlPosition
5885 ,sum(n) AS n
5886 ,case when sum(street0VPIChance) = 0 then '0'
5887 else to_char(100.0*sum(street0VPI)/sum(street0VPIChance),'990D0')
5888 end AS vpip
5889 ,case when sum(street0AggrChance) = 0 then '0'
5890 else to_char(100.0*sum(street0Aggr)/sum(street0AggrChance),'90D0')
5891 end AS pfr
5892 ,case when sum(street0CalledRaiseChance) = 0 then '0'
5893 else to_char(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),'90D0')
5894 end AS car0
5895 ,case when sum(street0_3Bchance) = 0 then '0'
5896 else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0')
5897 end AS pf3
5898 ,case when sum(street0_4Bchance) = 0 then '0'
5899 else to_char(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),'90D0')
5900 end AS pf4
5901 ,case when sum(street0_FoldTo3Bchance) = 0 then '0'
5902 else to_char(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),'90D0')
5903 end AS pff3
5904 ,case when sum(street0_FoldTo4Bchance) = 0 then '0'
5905 else to_char(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),'90D0')
5906 end AS pff4
5907 ,case when sum(raiseFirstInChance) = 0 then '-'
5908 else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0')
5909 end AS steals
5910 ,to_char(round(100.0*sum(street1Seen)/sum(n)),'90D0') AS saw_f
5911 ,to_char(round(100.0*sum(sawShowdown)/sum(n)),'90D0') AS sawsd
5912 ,case when sum(street1Seen) = 0 then '-'
5913 else to_char(round(100.0*sum(sawShowdown)/sum(street1Seen)),'90D0')
5914 end AS wtsdwsf
5915 ,case when sum(sawShowdown) = 0 then '-'
5916 else to_char(round(100.0*sum(wonAtSD)/sum(sawShowdown)),'90D0')
5917 end AS wmsd
5918 ,case when sum(street1Seen) = 0 then '-'
5919 else to_char(round(100.0*sum(street1Aggr)/sum(street1Seen)),'90D0')
5920 end AS FlAFq
5921 ,case when sum(street2Seen) = 0 then '-'
5922 else to_char(round(100.0*sum(street2Aggr)/sum(street2Seen)),'90D0')
5923 end AS TuAFq
5924 ,case when sum(street3Seen) = 0 then '-'
5925 else to_char(round(100.0*sum(street3Aggr)/sum(street3Seen)),'90D0')
5926 end AS RvAFq
5927 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-'
5928 else to_char(round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
5929 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))),'90D0')
5930 end AS PoFAFq
5931 ,to_char(sum(totalProfit)/100.0,'9G999G990D00') AS Net
5932 ,case when sum(n) = 0 then '0'
5933 else to_char(sum(totalProfit/(gt.bigBlind+0.0)) / (sum(n)/100.0), '990D00')
5934 end AS BBper100
5935 ,case when sum(n) = 0 then '0'
5936 else to_char( (sum(totalProfit)/100.0) / sum(n), '90D0000')
5937 end AS Profitperhand
5938 ,to_char(sum(seats*n)/(sum(n)+0.0),'90D00') AS AvgSeats
5939 from Gametypes gt
5940 inner join Sites s on (s.Id = gt.siteId)
5941 inner join HudCache hc on (hc.gametypeId = gt.Id)
5942 where hc.playerId in <player_test>
5943 <gtbigBlind_test>
5944 and hc.seats <seats_test>
5945 and '20' || SUBSTR(hc.styleKey,2,2) || '-' || SUBSTR(hc.styleKey,4,2) || '-'
5946 || SUBSTR(hc.styleKey,6,2) <datestest>
5947 group by gt.base
5948 ,gt.category
5949 ,upper(gt.limitType)
5950 ,s.name
5951 <groupbygt.bigBlind>
5952 ,gtId
5953 <groupbyseats>
5954 ,PlPosition
5955 ) stats
5956 inner join
5957 ( select /* profit from handsplayers/handsactions */
5958 hprof.gtId,
5959 case when hprof.position = 'B' then -2
5960 when hprof.position = 'S' then -1
5961 when hprof.position in ('3','4') then 2
5962 when hprof.position in ('6','7') then 5
5963 else cast(hprof.position as smallint)
5964 end as PlPosition,
5965 sum(hprof.profit) as sum_profit,
5966 avg(hprof.profit/100.0) as profitperhand,
5967 case when hprof.gtId = -1 then -999
5968 else variance(hprof.profit/100.0)
5969 end as variance
5970 ,case when hprof.gtId = -1 then -999
5971 else sqrt(variance(hprof.profit/100.0))
5972 end as stddev
5973 from
5974 (select hp.handId, <hgametypeId> as gtId, hp.position
5975 , hp.totalProfit as profit
5976 from HandsPlayers hp
5977 inner join Hands h ON (h.id = hp.handId)
5978 where hp.playerId in <player_test>
5979 and hp.tourneysPlayersId IS NULL
5980 and to_char(h.startTime, 'YYYY-MM-DD') <datestest>
5981 group by hp.handId, gametypeId, hp.position, hp.totalProfit
5982 ) hprof
5983 group by hprof.gtId, PlPosition
5984 ) hprof2
5985 on ( hprof2.gtId = stats.gtId
5986 and hprof2.PlPosition = stats.PlPosition)
5987 order by stats.category, stats.limitType, stats.bigBlindDesc desc
5988 <orderbyseats>, cast(stats.PlPosition as smallint)
5989 """
5991 ####################################
5992 # Cash Game Graph query
5993 ####################################
5994 self.query['getRingProfitAllHandsPlayerIdSite'] = """
5995 SELECT hp.handId, hp.totalProfit, hp.sawShowdown
5996 FROM HandsPlayers hp
5997 INNER JOIN Players pl ON (pl.id = hp.playerId)
5998 INNER JOIN Hands h ON (h.id = hp.handId)
5999 INNER JOIN Gametypes gt ON (gt.id = h.gametypeId)
6000 WHERE pl.id in <player_test>
6001 AND pl.siteId in <site_test>
6002 AND h.startTime > '<startdate_test>'
6003 AND h.startTime < '<enddate_test>'
6004 <limit_test>
6005 <game_test>
6006 AND gt.type = 'ring'
6007 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit
6008 ORDER BY h.startTime"""
6010 self.query['getRingProfitAllHandsPlayerIdSiteInBB'] = """
6011 SELECT hp.handId, ( hp.totalProfit / ( gt.bigBlind * 2.0 ) ) * 100 , hp.sawShowdown, ( hp.allInEV / ( gt.bigBlind * 2.0 ) ) * 100
6012 FROM HandsPlayers hp
6013 INNER JOIN Players pl ON (pl.id = hp.playerId)
6014 INNER JOIN Hands h ON (h.id = hp.handId)
6015 INNER JOIN Gametypes gt ON (gt.id = h.gametypeId)
6016 WHERE pl.id in <player_test>
6017 AND pl.siteId in <site_test>
6018 AND h.startTime > '<startdate_test>'
6019 AND h.startTime < '<enddate_test>'
6020 <limit_test>
6021 <game_test>
6022 <currency_test>
6023 AND hp.tourneysPlayersId IS NULL
6024 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit, hp.allInEV, gt.bigBlind
6025 ORDER BY h.startTime"""
6027 self.query['getRingProfitAllHandsPlayerIdSiteInDollars'] = """
6028 SELECT hp.handId, hp.totalProfit, hp.sawShowdown, hp.allInEV
6029 FROM HandsPlayers hp
6030 INNER JOIN Players pl ON (pl.id = hp.playerId)
6031 INNER JOIN Hands h ON (h.id = hp.handId)
6032 INNER JOIN Gametypes gt ON (gt.id = h.gametypeId)
6033 WHERE pl.id in <player_test>
6034 AND pl.siteId in <site_test>
6035 AND h.startTime > '<startdate_test>'
6036 AND h.startTime < '<enddate_test>'
6037 <limit_test>
6038 <game_test>
6039 <currency_test>
6040 AND hp.tourneysPlayersId IS NULL
6041 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit, hp.allInEV
6042 ORDER BY h.startTime"""
6044 ####################################
6045 # Tourney Results query
6046 ####################################
6047 self.query['tourneyResults'] = """
6048 SELECT tp.tourneyId, (coalesce(tp.winnings,0) - coalesce(tt.buyIn,0) - coalesce(tt.fee,0)) as profit, tp.koCount, tp.rebuyCount, tp.addOnCount, tt.buyIn, tt.fee, t.siteTourneyNo
6049 FROM TourneysPlayers tp
6050 INNER JOIN Players pl ON (pl.id = tp.playerId)
6051 INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
6052 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId)
6053 WHERE pl.id in <player_test>
6054 AND pl.siteId in <site_test>
6055 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
6056 OR t.startTime is NULL)
6057 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency,
6058 tp.winnings, tp.koCount,
6059 tp.rebuyCount, tp.addOnCount,
6060 tt.buyIn, tt.fee, t.siteTourneyNo
6061 ORDER BY t.startTime"""
6063 #AND gt.type = 'ring'
6064 #<limit_test>
6065 #<game_test>
6067 ####################################
6068 # Tourney Graph query
6069 # FIXME this is a horrible hack to prevent nonsense data
6070 # being graphed - needs proper fix mantis #180 +#182
6071 ####################################
6072 self.query['tourneyGraph'] = """
6073 SELECT tp.tourneyId, (coalesce(tp.winnings,0) - coalesce(tt.buyIn,0) - coalesce(tt.fee,0)) as profit, tp.koCount, tp.rebuyCount, tp.addOnCount, tt.buyIn, tt.fee, t.siteTourneyNo
6074 FROM TourneysPlayers tp
6075 INNER JOIN Players pl ON (pl.id = tp.playerId)
6076 INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
6077 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId)
6078 WHERE pl.id in <player_test>
6079 AND pl.siteId in <site_test>
6080 AND (t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
6081 <currency_test>
6082 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency,
6083 tp.winnings, tp.koCount,
6084 tp.rebuyCount, tp.addOnCount,
6085 tt.buyIn, tt.fee, t.siteTourneyNo
6086 ORDER BY t.startTime"""
6088 #AND gt.type = 'ring'
6089 #<limit_test>
6090 #<game_test>
6091 ####################################
6092 # Tourney Graph query with tourneytypefilter
6093 # FIXME this is a horrible hack to prevent nonsense data
6094 # being graphed - needs proper fix mantis #180 +#182
6095 ####################################
6096 self.query['tourneyGraphType'] = """
6097 SELECT tp.tourneyId, (coalesce(tp.winnings,0) - coalesce(tt.buyIn,0) - coalesce(tt.fee,0)) as profit, tp.koCount, tp.rebuyCount, tp.addOnCount, tt.buyIn, tt.fee, t.siteTourneyNo
6098 FROM TourneysPlayers tp
6099 INNER JOIN Players pl ON (pl.id = tp.playerId)
6100 INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
6101 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId)
6102 WHERE pl.id in <player_test>
6103 AND pl.siteId in <site_test>
6104 AND tt.category in <tourney_cat>
6105 AND tt.limitType in <tourney_lim>
6106 AND tt.buyin in <tourney_buyin>
6107 AND (t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>')
6108 <currency_test>
6109 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency,
6110 tp.winnings, tp.koCount,
6111 tp.rebuyCount, tp.addOnCount,
6112 tt.buyIn, tt.fee, t.siteTourneyNo
6113 ORDER BY t.startTime"""
6115 #AND gt.type = 'ring'
6116 #<limit_test>
6117 #<game_test>
6119 ####################################
6120 # Session stats query
6121 ####################################
6122 if db_server == 'mysql':
6123 self.query['sessionStats'] = """
6124 SELECT UNIX_TIMESTAMP(h.startTime) as time, hp.totalProfit
6125 FROM HandsPlayers hp
6126 INNER JOIN Hands h on (h.id = hp.handId)
6127 INNER JOIN Gametypes gt on (gt.Id = h.gametypeId)
6128 INNER JOIN Sites s on (s.Id = gt.siteId)
6129 INNER JOIN Players p on (p.Id = hp.playerId)
6130 WHERE hp.playerId in <player_test>
6131 AND date_format(h.startTime, '%Y-%m-%d') <datestest>
6132 AND gt.type LIKE 'ring'
6133 <limit_test>
6134 <game_test>
6135 <seats_test>
6136 <currency_test>
6137 ORDER by time"""
6138 elif db_server == 'postgresql':
6139 self.query['sessionStats'] = """
6140 SELECT EXTRACT(epoch from h.startTime) as time, hp.totalProfit
6141 FROM HandsPlayers hp
6142 INNER JOIN Hands h on (h.id = hp.handId)
6143 INNER JOIN Gametypes gt on (gt.Id = h.gametypeId)
6144 INNER JOIN Sites s on (s.Id = gt.siteId)
6145 INNER JOIN Players p on (p.Id = hp.playerId)
6146 WHERE hp.playerId in <player_test>
6147 AND h.startTime <datestest>
6148 AND gt.type LIKE 'ring'
6149 <limit_test>
6150 <game_test>
6151 <seats_test>
6152 <currency_test>
6153 ORDER by time"""
6154 elif db_server == 'sqlite':
6155 self.query['sessionStats'] = """
6156 SELECT STRFTIME('<ampersand_s>', h.startTime) as time, hp.totalProfit
6157 FROM HandsPlayers hp
6158 INNER JOIN Hands h on (h.id = hp.handId)
6159 INNER JOIN Gametypes gt on (gt.Id = h.gametypeId)
6160 INNER JOIN Sites s on (s.Id = gt.siteId)
6161 INNER JOIN Players p on (p.Id = hp.playerId)
6162 WHERE hp.playerId in <player_test>
6163 AND h.startTime <datestest>
6164 AND gt.type is 'ring'
6165 <limit_test>
6166 <game_test>
6167 <seats_test>
6168 <currency_test>
6169 ORDER by time"""
6171 ####################################
6172 # Querry to get all hands in a date range
6173 ####################################
6174 self.query['handsInRange'] = """
6175 select h.id
6176 from Hands h
6177 join HandsPlayers hp on h.id = hp.handId
6178 join Gametypes gt on gt.id = h.gametypeId
6179 where h.startTime <datetest>
6180 and hp.playerId in <player_test>
6181 <game_test>
6182 <limit_test>
6183 <position_test>"""
6185 ####################################
6186 # Querry to get all hands in a date range for cash games session
6187 ####################################
6188 self.query['handsInRangeSession'] = """
6189 select h.id
6190 from Hands h
6192 where h.startTime <datetest>
6193 """
6196 ####################################
6197 # Querry to get all hands in a date range for cash games session variation filter
6198 ####################################
6199 self.query['handsInRangeSessionFilter'] = """
6200 select h.id
6201 from Hands h
6202 join Gametypes gt on h.gametypeId = gt.id
6203 join HandsPlayers hp on h.id = hp.handId -- utilisation de HandsPlayers
6204 where h.startTime <datetest>
6205 <game_test>
6206 <limit_test>
6207 <player_test>
6208 <position_test>
6209 """
6211 self.query['getPlayerId'] = """
6212 SELECT id
6213 FROM Players
6214 WHERE siteId = %s
6215 AND name = %s
6216 """
6218 ####################################
6219 # Query to get a single hand for the replayer
6220 ####################################
6221 self.query['singleHand'] = """
6222 SELECT h.*
6223 FROM Hands h
6224 WHERE id = %s"""
6226 ####################################
6227 # Query to get run it twice boards for the replayer
6228 ####################################
6229 self.query['singleHandBoards'] = """
6230 SELECT b.*
6231 FROM Boards b
6232 WHERE handId = %s"""
6234 ####################################
6235 # Query to get a single player hand for the replayer
6236 ####################################
6237 self.query['playerHand'] = """
6238 SELECT
6239 hp.seatno,
6240 round(hp.winnings / 100.0,2) as winnings,
6241 p.name,
6242 round(hp.startCash / 100.0,2) as chips,
6243 hp.card1,hp.card2,hp.card3,hp.card4,hp.card5,
6244 hp.card6,hp.card7,hp.card8,hp.card9,hp.card10,
6245 hp.card11,hp.card12,hp.card13,hp.card14,hp.card15,
6246 hp.card16,hp.card17,hp.card18,hp.card19,hp.card20,
6247 hp.position,
6248 round(hp.startBounty / 100.0,2) as bounty,
6249 hp.sitout
6250 FROM
6251 HandsPlayers as hp,
6252 Players as p
6253 WHERE
6254 hp.handId = %s
6255 and p.id = hp.playerId
6256 ORDER BY
6257 hp.seatno
6258 """
6260 ####################################
6261 # Query for the actions of a hand
6262 ####################################
6263 self.query['handActions'] = """
6264 SELECT
6265 ha.actionNo,
6266 p.name,
6267 ha.street,
6268 ha.actionId,
6269 ha.allIn,
6270 round(ha.amount / 100.0,2) as bet,
6271 ha.numDiscarded,
6272 ha.cardsDiscarded
6273 FROM
6274 HandsActions as ha,
6275 Players as p,
6276 Hands as h
6277 WHERE
6278 h.id = %s
6279 AND ha.handId = h.id
6280 AND ha.playerId = p.id
6281 ORDER BY
6282 ha.id ASC
6283 """
6285 ####################################
6286 # Queries to rebuild/modify hudcache
6287 ####################################
6289 self.query['clearHudCache'] = """DELETE FROM HudCache"""
6290 self.query['clearCardsCache'] = """DELETE FROM CardsCache"""
6291 self.query['clearPositionsCache'] = """DELETE FROM PositionsCache"""
6293 self.query['clearHudCacheTourneyType'] = """DELETE FROM HudCache WHERE tourneyTypeId = %s"""
6294 self.query['clearCardsCacheTourneyType'] = """DELETE FROM CardsCache WHERE tourneyTypeId = %s"""
6295 self.query['clearPositionsCacheTourneyType'] = """DELETE FROM PositionsCache WHERE tourneyTypeId = %s"""
6297 self.query['fetchNewHudCacheTourneyTypeIds'] = """SELECT TT.id
6298 FROM TourneyTypes TT
6299 LEFT OUTER JOIN HudCache HC ON (TT.id = HC.tourneyTypeId)
6300 WHERE HC.tourneyTypeId is NULL
6301 """
6303 self.query['fetchNewCardsCacheTourneyTypeIds'] = """SELECT TT.id
6304 FROM TourneyTypes TT
6305 LEFT OUTER JOIN CardsCache CC ON (TT.id = CC.tourneyTypeId)
6306 WHERE CC.tourneyTypeId is NULL
6307 """
6309 self.query['fetchNewPositionsCacheTourneyTypeIds'] = """SELECT TT.id
6310 FROM TourneyTypes TT
6311 LEFT OUTER JOIN PositionsCache PC ON (TT.id = PC.tourneyTypeId)
6312 WHERE PC.tourneyTypeId is NULL
6313 """
6315 self.query['clearCardsCacheWeeksMonths'] = """DELETE FROM CardsCache WHERE weekId = %s AND monthId = %s"""
6316 self.query['clearPositionsCacheWeeksMonths'] = """DELETE FROM PositionsCache WHERE weekId = %s AND monthId = %s"""
6318 self.query['selectSessionWithWeekId'] = """SELECT id FROM Sessions WHERE weekId = %s"""
6319 self.query['selectSessionWithMonthId'] = """SELECT id FROM Sessions WHERE monthId = %s"""
6321 self.query['deleteWeekId'] = """DELETE FROM Weeks WHERE id = %s"""
6322 self.query['deleteMonthId'] = """DELETE FROM Months WHERE id = %s"""
6324 self.query['fetchNewCardsCacheWeeksMonths'] = """SELECT SCG.weekId, SCG.monthId
6325 FROM (SELECT DISTINCT weekId, monthId FROM Sessions) SCG
6326 LEFT OUTER JOIN CardsCache CC ON (SCG.weekId = CC.weekId AND SCG.monthId = CC.monthId)
6327 WHERE CC.weekId is NULL OR CC.monthId is NULL
6328 """
6330 self.query['fetchNewPositionsCacheWeeksMonths'] = """SELECT SCG.weekId, SCG.monthId
6331 FROM (SELECT DISTINCT weekId, monthId FROM Sessions) SCG
6332 LEFT OUTER JOIN PositionsCache PC ON (SCG.weekId = PC.weekId AND SCG.monthId = PC.monthId)
6333 WHERE PC.weekId is NULL OR PC.monthId is NULL
6334 """
6338 if db_server == 'mysql':
6339 self.query['rebuildCache'] = """insert into <insert>
6340 ,n
6341 ,street0VPIChance
6342 ,street0VPI
6343 ,street0AggrChance
6344 ,street0Aggr
6345 ,street0CalledRaiseChance
6346 ,street0CalledRaiseDone
6347 ,street0_2BChance
6348 ,street0_2BDone
6349 ,street0_3BChance
6350 ,street0_3BDone
6351 ,street0_4BChance
6352 ,street0_4BDone
6353 ,street0_C4BChance
6354 ,street0_C4BDone
6355 ,street0_FoldTo2BChance
6356 ,street0_FoldTo2BDone
6357 ,street0_FoldTo3BChance
6358 ,street0_FoldTo3BDone
6359 ,street0_FoldTo4BChance
6360 ,street0_FoldTo4BDone
6361 ,street0_SqueezeChance
6362 ,street0_SqueezeDone
6363 ,raiseToStealChance
6364 ,raiseToStealDone
6365 ,stealChance
6366 ,stealDone
6367 ,success_Steal
6368 ,street1Seen
6369 ,street2Seen
6370 ,street3Seen
6371 ,street4Seen
6372 ,sawShowdown
6373 ,street1Aggr
6374 ,street2Aggr
6375 ,street3Aggr
6376 ,street4Aggr
6377 ,otherRaisedStreet0
6378 ,otherRaisedStreet1
6379 ,otherRaisedStreet2
6380 ,otherRaisedStreet3
6381 ,otherRaisedStreet4
6382 ,foldToOtherRaisedStreet0
6383 ,foldToOtherRaisedStreet1
6384 ,foldToOtherRaisedStreet2
6385 ,foldToOtherRaisedStreet3
6386 ,foldToOtherRaisedStreet4
6387 ,wonWhenSeenStreet1
6388 ,wonWhenSeenStreet2
6389 ,wonWhenSeenStreet3
6390 ,wonWhenSeenStreet4
6391 ,wonAtSD
6392 ,raiseFirstInChance
6393 ,raisedFirstIn
6394 ,foldBbToStealChance
6395 ,foldedBbToSteal
6396 ,foldSbToStealChance
6397 ,foldedSbToSteal
6398 ,street1CBChance
6399 ,street1CBDone
6400 ,street2CBChance
6401 ,street2CBDone
6402 ,street3CBChance
6403 ,street3CBDone
6404 ,street4CBChance
6405 ,street4CBDone
6406 ,foldToStreet1CBChance
6407 ,foldToStreet1CBDone
6408 ,foldToStreet2CBChance
6409 ,foldToStreet2CBDone
6410 ,foldToStreet3CBChance
6411 ,foldToStreet3CBDone
6412 ,foldToStreet4CBChance
6413 ,foldToStreet4CBDone
6414 ,common
6415 ,committed
6416 ,winnings
6417 ,rake
6418 ,rakeDealt
6419 ,rakeContributed
6420 ,rakeWeighted
6421 ,totalProfit
6422 ,allInEV
6423 ,showdownWinnings
6424 ,nonShowdownWinnings
6425 ,street1CheckCallRaiseChance
6426 ,street1CheckCallDone
6427 ,street1CheckRaiseDone
6428 ,street2CheckCallRaiseChance
6429 ,street2CheckCallDone
6430 ,street2CheckRaiseDone
6431 ,street3CheckCallRaiseChance
6432 ,street3CheckCallDone
6433 ,street3CheckRaiseDone
6434 ,street4CheckCallRaiseChance
6435 ,street4CheckCallDone
6436 ,street4CheckRaiseDone
6437 ,street0Calls
6438 ,street1Calls
6439 ,street2Calls
6440 ,street3Calls
6441 ,street4Calls
6442 ,street0Bets
6443 ,street1Bets
6444 ,street2Bets
6445 ,street3Bets
6446 ,street4Bets
6447 ,street0Raises
6448 ,street1Raises
6449 ,street2Raises
6450 ,street3Raises
6451 ,street4Raises
6452 ,street1Discards
6453 ,street2Discards
6454 ,street3Discards
6455 )
6456 SELECT <select>
6457 ,count(1)
6458 ,sum(street0VPIChance)
6459 ,sum(street0VPI)
6460 ,sum(street0AggrChance)
6461 ,sum(street0Aggr)
6462 ,sum(street0CalledRaiseChance)
6463 ,sum(street0CalledRaiseDone)
6464 ,sum(street0_2BChance)
6465 ,sum(street0_2BDone)
6466 ,sum(street0_3BChance)
6467 ,sum(street0_3BDone)
6468 ,sum(street0_4BChance)
6469 ,sum(street0_4BDone)
6470 ,sum(street0_C4BChance)
6471 ,sum(street0_C4BDone)
6472 ,sum(street0_FoldTo2BChance)
6473 ,sum(street0_FoldTo2BDone)
6474 ,sum(street0_FoldTo3BChance)
6475 ,sum(street0_FoldTo3BDone)
6476 ,sum(street0_FoldTo4BChance)
6477 ,sum(street0_FoldTo4BDone)
6478 ,sum(street0_SqueezeChance)
6479 ,sum(street0_SqueezeDone)
6480 ,sum(raiseToStealChance)
6481 ,sum(raiseToStealDone)
6482 ,sum(stealChance)
6483 ,sum(stealDone)
6484 ,sum(success_Steal)
6485 ,sum(street1Seen)
6486 ,sum(street2Seen)
6487 ,sum(street3Seen)
6488 ,sum(street4Seen)
6489 ,sum(sawShowdown)
6490 ,sum(street1Aggr)
6491 ,sum(street2Aggr)
6492 ,sum(street3Aggr)
6493 ,sum(street4Aggr)
6494 ,sum(otherRaisedStreet0)
6495 ,sum(otherRaisedStreet1)
6496 ,sum(otherRaisedStreet2)
6497 ,sum(otherRaisedStreet3)
6498 ,sum(otherRaisedStreet4)
6499 ,sum(foldToOtherRaisedStreet0)
6500 ,sum(foldToOtherRaisedStreet1)
6501 ,sum(foldToOtherRaisedStreet2)
6502 ,sum(foldToOtherRaisedStreet3)
6503 ,sum(foldToOtherRaisedStreet4)
6504 ,sum(wonWhenSeenStreet1)
6505 ,sum(wonWhenSeenStreet2)
6506 ,sum(wonWhenSeenStreet3)
6507 ,sum(wonWhenSeenStreet4)
6508 ,sum(wonAtSD)
6509 ,sum(raiseFirstInChance)
6510 ,sum(raisedFirstIn)
6511 ,sum(foldBbToStealChance)
6512 ,sum(foldedBbToSteal)
6513 ,sum(foldSbToStealChance)
6514 ,sum(foldedSbToSteal)
6515 ,sum(street1CBChance)
6516 ,sum(street1CBDone)
6517 ,sum(street2CBChance)
6518 ,sum(street2CBDone)
6519 ,sum(street3CBChance)
6520 ,sum(street3CBDone)
6521 ,sum(street4CBChance)
6522 ,sum(street4CBDone)
6523 ,sum(foldToStreet1CBChance)
6524 ,sum(foldToStreet1CBDone)
6525 ,sum(foldToStreet2CBChance)
6526 ,sum(foldToStreet2CBDone)
6527 ,sum(foldToStreet3CBChance)
6528 ,sum(foldToStreet3CBDone)
6529 ,sum(foldToStreet4CBChance)
6530 ,sum(foldToStreet4CBDone)
6531 ,sum(common)
6532 ,sum(committed)
6533 ,sum(winnings)
6534 ,sum(rake)
6535 ,sum(rakeDealt)
6536 ,sum(rakeContributed)
6537 ,sum(rakeWeighted)
6538 ,sum(totalProfit)
6539 ,sum(allInEV)
6540 ,sum(case when sawShowdown = 1 then totalProfit else 0 end)
6541 ,sum(case when sawShowdown = 0 then totalProfit else 0 end)
6542 ,sum(street1CheckCallRaiseChance)
6543 ,sum(street1CheckCallDone)
6544 ,sum(street1CheckRaiseDone)
6545 ,sum(street2CheckCallRaiseChance)
6546 ,sum(street2CheckCallDone)
6547 ,sum(street2CheckRaiseDone)
6548 ,sum(street3CheckCallRaiseChance)
6549 ,sum(street3CheckCallDone)
6550 ,sum(street3CheckRaiseDone)
6551 ,sum(street4CheckCallRaiseChance)
6552 ,sum(street4CheckCallDone)
6553 ,sum(street4CheckRaiseDone)
6554 ,sum(street0Calls)
6555 ,sum(street1Calls)
6556 ,sum(street2Calls)
6557 ,sum(street3Calls)
6558 ,sum(street4Calls)
6559 ,sum(street0Bets)
6560 ,sum(street1Bets)
6561 ,sum(street2Bets)
6562 ,sum(street3Bets)
6563 ,sum(street4Bets)
6564 ,sum(hp.street0Raises)
6565 ,sum(hp.street1Raises)
6566 ,sum(hp.street2Raises)
6567 ,sum(hp.street3Raises)
6568 ,sum(hp.street4Raises)
6569 ,sum(street1Discards)
6570 ,sum(street2Discards)
6571 ,sum(street3Discards)
6572 FROM Hands h
6573 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>)
6574 INNER JOIN Gametypes g ON (h.gametypeId = g.id)
6575 <sessions_join_clause>
6576 <tourney_join_clause>
6577 <where_clause>
6578 GROUP BY <group>
6579"""
6580 elif db_server == 'postgresql':
6581 self.query['rebuildCache'] = """insert into <insert>
6582 ,n
6583 ,street0VPIChance
6584 ,street0VPI
6585 ,street0AggrChance
6586 ,street0Aggr
6587 ,street0CalledRaiseChance
6588 ,street0CalledRaiseDone
6589 ,street0_2BChance
6590 ,street0_2BDone
6591 ,street0_3BChance
6592 ,street0_3BDone
6593 ,street0_4BChance
6594 ,street0_4BDone
6595 ,street0_C4BChance
6596 ,street0_C4BDone
6597 ,street0_FoldTo2BChance
6598 ,street0_FoldTo2BDone
6599 ,street0_FoldTo3BChance
6600 ,street0_FoldTo3BDone
6601 ,street0_FoldTo4BChance
6602 ,street0_FoldTo4BDone
6603 ,street0_SqueezeChance
6604 ,street0_SqueezeDone
6605 ,raiseToStealChance
6606 ,raiseToStealDone
6607 ,stealChance
6608 ,stealDone
6609 ,success_Steal
6610 ,street1Seen
6611 ,street2Seen
6612 ,street3Seen
6613 ,street4Seen
6614 ,sawShowdown
6615 ,street1Aggr
6616 ,street2Aggr
6617 ,street3Aggr
6618 ,street4Aggr
6619 ,otherRaisedStreet0
6620 ,otherRaisedStreet1
6621 ,otherRaisedStreet2
6622 ,otherRaisedStreet3
6623 ,otherRaisedStreet4
6624 ,foldToOtherRaisedStreet0
6625 ,foldToOtherRaisedStreet1
6626 ,foldToOtherRaisedStreet2
6627 ,foldToOtherRaisedStreet3
6628 ,foldToOtherRaisedStreet4
6629 ,wonWhenSeenStreet1
6630 ,wonWhenSeenStreet2
6631 ,wonWhenSeenStreet3
6632 ,wonWhenSeenStreet4
6633 ,wonAtSD
6634 ,raiseFirstInChance
6635 ,raisedFirstIn
6636 ,foldBbToStealChance
6637 ,foldedBbToSteal
6638 ,foldSbToStealChance
6639 ,foldedSbToSteal
6640 ,street1CBChance
6641 ,street1CBDone
6642 ,street2CBChance
6643 ,street2CBDone
6644 ,street3CBChance
6645 ,street3CBDone
6646 ,street4CBChance
6647 ,street4CBDone
6648 ,foldToStreet1CBChance
6649 ,foldToStreet1CBDone
6650 ,foldToStreet2CBChance
6651 ,foldToStreet2CBDone
6652 ,foldToStreet3CBChance
6653 ,foldToStreet3CBDone
6654 ,foldToStreet4CBChance
6655 ,foldToStreet4CBDone
6656 ,common
6657 ,committed
6658 ,winnings
6659 ,rake
6660 ,rakeDealt
6661 ,rakeContributed
6662 ,rakeWeighted
6663 ,totalProfit
6664 ,allInEV
6665 ,showdownWinnings
6666 ,nonShowdownWinnings
6667 ,street1CheckCallRaiseChance
6668 ,street1CheckCallDone
6669 ,street1CheckRaiseDone
6670 ,street2CheckCallRaiseChance
6671 ,street2CheckCallDone
6672 ,street2CheckRaiseDone
6673 ,street3CheckCallRaiseChance
6674 ,street3CheckCallDone
6675 ,street3CheckRaiseDone
6676 ,street4CheckCallRaiseChance
6677 ,street4CheckCallDone
6678 ,street4CheckRaiseDone
6679 ,street0Calls
6680 ,street1Calls
6681 ,street2Calls
6682 ,street3Calls
6683 ,street4Calls
6684 ,street0Bets
6685 ,street1Bets
6686 ,street2Bets
6687 ,street3Bets
6688 ,street4Bets
6689 ,street0Raises
6690 ,street1Raises
6691 ,street2Raises
6692 ,street3Raises
6693 ,street4Raises
6694 ,street1Discards
6695 ,street2Discards
6696 ,street3Discards
6697 )
6698 SELECT <select>
6699 ,count(1)
6700 ,sum(CAST(street0VPIChance as integer))
6701 ,sum(CAST(street0VPI as integer))
6702 ,sum(CAST(street0AggrChance as integer))
6703 ,sum(CAST(street0Aggr as integer))
6704 ,sum(CAST(street0CalledRaiseChance as integer))
6705 ,sum(CAST(street0CalledRaiseDone as integer))
6706 ,sum(CAST(street0_2BChance as integer))
6707 ,sum(CAST(street0_2BDone as integer))
6708 ,sum(CAST(street0_3BChance as integer))
6709 ,sum(CAST(street0_3BDone as integer))
6710 ,sum(CAST(street0_4BChance as integer))
6711 ,sum(CAST(street0_4BDone as integer))
6712 ,sum(CAST(street0_C4BChance as integer))
6713 ,sum(CAST(street0_C4BDone as integer))
6714 ,sum(CAST(street0_FoldTo2BChance as integer))
6715 ,sum(CAST(street0_FoldTo2BDone as integer))
6716 ,sum(CAST(street0_FoldTo3BChance as integer))
6717 ,sum(CAST(street0_FoldTo3BDone as integer))
6718 ,sum(CAST(street0_FoldTo4BChance as integer))
6719 ,sum(CAST(street0_FoldTo4BDone as integer))
6720 ,sum(CAST(street0_SqueezeChance as integer))
6721 ,sum(CAST(street0_SqueezeDone as integer))
6722 ,sum(CAST(raiseToStealChance as integer))
6723 ,sum(CAST(raiseToStealDone as integer))
6724 ,sum(CAST(stealChance as integer))
6725 ,sum(CAST(stealDone as integer))
6726 ,sum(CAST(success_Steal as integer))
6727 ,sum(CAST(street1Seen as integer))
6728 ,sum(CAST(street2Seen as integer))
6729 ,sum(CAST(street3Seen as integer))
6730 ,sum(CAST(street4Seen as integer))
6731 ,sum(CAST(sawShowdown as integer))
6732 ,sum(CAST(street1Aggr as integer))
6733 ,sum(CAST(street2Aggr as integer))
6734 ,sum(CAST(street3Aggr as integer))
6735 ,sum(CAST(street4Aggr as integer))
6736 ,sum(CAST(otherRaisedStreet0 as integer))
6737 ,sum(CAST(otherRaisedStreet1 as integer))
6738 ,sum(CAST(otherRaisedStreet2 as integer))
6739 ,sum(CAST(otherRaisedStreet3 as integer))
6740 ,sum(CAST(otherRaisedStreet4 as integer))
6741 ,sum(CAST(foldToOtherRaisedStreet0 as integer))
6742 ,sum(CAST(foldToOtherRaisedStreet1 as integer))
6743 ,sum(CAST(foldToOtherRaisedStreet2 as integer))
6744 ,sum(CAST(foldToOtherRaisedStreet3 as integer))
6745 ,sum(CAST(foldToOtherRaisedStreet4 as integer))
6746 ,sum(CAST(wonWhenSeenStreet1 as integer))
6747 ,sum(CAST(wonWhenSeenStreet2 as integer))
6748 ,sum(CAST(wonWhenSeenStreet3 as integer))
6749 ,sum(CAST(wonWhenSeenStreet4 as integer))
6750 ,sum(CAST(wonAtSD as integer))
6751 ,sum(CAST(raiseFirstInChance as integer))
6752 ,sum(CAST(raisedFirstIn as integer))
6753 ,sum(CAST(foldBbToStealChance as integer))
6754 ,sum(CAST(foldedBbToSteal as integer))
6755 ,sum(CAST(foldSbToStealChance as integer))
6756 ,sum(CAST(foldedSbToSteal as integer))
6757 ,sum(CAST(street1CBChance as integer))
6758 ,sum(CAST(street1CBDone as integer))
6759 ,sum(CAST(street2CBChance as integer))
6760 ,sum(CAST(street2CBDone as integer))
6761 ,sum(CAST(street3CBChance as integer))
6762 ,sum(CAST(street3CBDone as integer))
6763 ,sum(CAST(street4CBChance as integer))
6764 ,sum(CAST(street4CBDone as integer))
6765 ,sum(CAST(foldToStreet1CBChance as integer))
6766 ,sum(CAST(foldToStreet1CBDone as integer))
6767 ,sum(CAST(foldToStreet2CBChance as integer))
6768 ,sum(CAST(foldToStreet2CBDone as integer))
6769 ,sum(CAST(foldToStreet3CBChance as integer))
6770 ,sum(CAST(foldToStreet3CBDone as integer))
6771 ,sum(CAST(foldToStreet4CBChance as integer))
6772 ,sum(CAST(foldToStreet4CBDone as integer))
6773 ,sum(common)
6774 ,sum(committed)
6775 ,sum(winnings)
6776 ,sum(rake)
6777 ,sum(rakeDealt)
6778 ,sum(rakeContributed)
6779 ,sum(rakeWeighted)
6780 ,sum(totalProfit)
6781 ,sum(allInEV)
6782 ,sum(case when sawShowdown then totalProfit else 0 end)
6783 ,sum(case when sawShowdown then 0 else totalProfit end)
6784 ,sum(CAST(street1CheckCallRaiseChance as integer))
6785 ,sum(CAST(street1CheckCallDone as integer))
6786 ,sum(CAST(street1CheckRaiseDone as integer))
6787 ,sum(CAST(street2CheckCallRaiseChance as integer))
6788 ,sum(CAST(street2CheckCallDone as integer))
6789 ,sum(CAST(street2CheckRaiseDone as integer))
6790 ,sum(CAST(street3CheckCallRaiseChance as integer))
6791 ,sum(CAST(street3CheckCallDone as integer))
6792 ,sum(CAST(street3CheckRaiseDone as integer))
6793 ,sum(CAST(street4CheckCallRaiseChance as integer))
6794 ,sum(CAST(street4CheckCallDone as integer))
6795 ,sum(CAST(street4CheckRaiseDone as integer))
6796 ,sum(CAST(street0Calls as integer))
6797 ,sum(CAST(street1Calls as integer))
6798 ,sum(CAST(street2Calls as integer))
6799 ,sum(CAST(street3Calls as integer))
6800 ,sum(CAST(street4Calls as integer))
6801 ,sum(CAST(street0Bets as integer))
6802 ,sum(CAST(street1Bets as integer))
6803 ,sum(CAST(street2Bets as integer))
6804 ,sum(CAST(street3Bets as integer))
6805 ,sum(CAST(street4Bets as integer))
6806 ,sum(CAST(hp.street0Raises as integer))
6807 ,sum(CAST(hp.street1Raises as integer))
6808 ,sum(CAST(hp.street2Raises as integer))
6809 ,sum(CAST(hp.street3Raises as integer))
6810 ,sum(CAST(hp.street4Raises as integer))
6811 ,sum(CAST(street1Discards as integer))
6812 ,sum(CAST(street2Discards as integer))
6813 ,sum(CAST(street3Discards as integer))
6814 FROM Hands h
6815 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>)
6816 INNER JOIN Gametypes g ON (h.gametypeId = g.id)
6817 <sessions_join_clause>
6818 <tourney_join_clause>
6819 <where_clause>
6820 GROUP BY <group>
6821"""
6822 elif db_server == 'sqlite':
6823 self.query['rebuildCache'] = """insert into <insert>
6824 ,n
6825 ,street0VPIChance
6826 ,street0VPI
6827 ,street0AggrChance
6828 ,street0Aggr
6829 ,street0CalledRaiseChance
6830 ,street0CalledRaiseDone
6831 ,street0_2BChance
6832 ,street0_2BDone
6833 ,street0_3BChance
6834 ,street0_3BDone
6835 ,street0_4BChance
6836 ,street0_4BDone
6837 ,street0_C4BChance
6838 ,street0_C4BDone
6839 ,street0_FoldTo2BChance
6840 ,street0_FoldTo2BDone
6841 ,street0_FoldTo3BChance
6842 ,street0_FoldTo3BDone
6843 ,street0_FoldTo4BChance
6844 ,street0_FoldTo4BDone
6845 ,street0_SqueezeChance
6846 ,street0_SqueezeDone
6847 ,raiseToStealChance
6848 ,raiseToStealDone
6849 ,stealChance
6850 ,stealDone
6851 ,success_Steal
6852 ,street1Seen
6853 ,street2Seen
6854 ,street3Seen
6855 ,street4Seen
6856 ,sawShowdown
6857 ,street1Aggr
6858 ,street2Aggr
6859 ,street3Aggr
6860 ,street4Aggr
6861 ,otherRaisedStreet0
6862 ,otherRaisedStreet1
6863 ,otherRaisedStreet2
6864 ,otherRaisedStreet3
6865 ,otherRaisedStreet4
6866 ,foldToOtherRaisedStreet0
6867 ,foldToOtherRaisedStreet1
6868 ,foldToOtherRaisedStreet2
6869 ,foldToOtherRaisedStreet3
6870 ,foldToOtherRaisedStreet4
6871 ,wonWhenSeenStreet1
6872 ,wonWhenSeenStreet2
6873 ,wonWhenSeenStreet3
6874 ,wonWhenSeenStreet4
6875 ,wonAtSD
6876 ,raiseFirstInChance
6877 ,raisedFirstIn
6878 ,foldBbToStealChance
6879 ,foldedBbToSteal
6880 ,foldSbToStealChance
6881 ,foldedSbToSteal
6882 ,street1CBChance
6883 ,street1CBDone
6884 ,street2CBChance
6885 ,street2CBDone
6886 ,street3CBChance
6887 ,street3CBDone
6888 ,street4CBChance
6889 ,street4CBDone
6890 ,foldToStreet1CBChance
6891 ,foldToStreet1CBDone
6892 ,foldToStreet2CBChance
6893 ,foldToStreet2CBDone
6894 ,foldToStreet3CBChance
6895 ,foldToStreet3CBDone
6896 ,foldToStreet4CBChance
6897 ,foldToStreet4CBDone
6898 ,common
6899 ,committed
6900 ,winnings
6901 ,rake
6902 ,rakeDealt
6903 ,rakeContributed
6904 ,rakeWeighted
6905 ,totalProfit
6906 ,allInEV
6907 ,showdownWinnings
6908 ,nonShowdownWinnings
6909 ,street1CheckCallRaiseChance
6910 ,street1CheckCallDone
6911 ,street1CheckRaiseDone
6912 ,street2CheckCallRaiseChance
6913 ,street2CheckCallDone
6914 ,street2CheckRaiseDone
6915 ,street3CheckCallRaiseChance
6916 ,street3CheckCallDone
6917 ,street3CheckRaiseDone
6918 ,street4CheckCallRaiseChance
6919 ,street4CheckCallDone
6920 ,street4CheckRaiseDone
6921 ,street0Calls
6922 ,street1Calls
6923 ,street2Calls
6924 ,street3Calls
6925 ,street4Calls
6926 ,street0Bets
6927 ,street1Bets
6928 ,street2Bets
6929 ,street3Bets
6930 ,street4Bets
6931 ,street0Raises
6932 ,street1Raises
6933 ,street2Raises
6934 ,street3Raises
6935 ,street4Raises
6936 ,street1Discards
6937 ,street2Discards
6938 ,street3Discards
6939 )
6940 SELECT <select>
6941 ,count(1)
6942 ,sum(CAST(street0VPIChance as integer))
6943 ,sum(CAST(street0VPI as integer))
6944 ,sum(CAST(street0AggrChance as integer))
6945 ,sum(CAST(street0Aggr as integer))
6946 ,sum(CAST(street0CalledRaiseChance as integer))
6947 ,sum(CAST(street0CalledRaiseDone as integer))
6948 ,sum(CAST(street0_2BChance as integer))
6949 ,sum(CAST(street0_2BDone as integer))
6950 ,sum(CAST(street0_3BChance as integer))
6951 ,sum(CAST(street0_3BDone as integer))
6952 ,sum(CAST(street0_4BChance as integer))
6953 ,sum(CAST(street0_4BDone as integer))
6954 ,sum(CAST(street0_C4BChance as integer))
6955 ,sum(CAST(street0_C4BDone as integer))
6956 ,sum(CAST(street0_FoldTo2BChance as integer))
6957 ,sum(CAST(street0_FoldTo2BDone as integer))
6958 ,sum(CAST(street0_FoldTo3BChance as integer))
6959 ,sum(CAST(street0_FoldTo3BDone as integer))
6960 ,sum(CAST(street0_FoldTo4BChance as integer))
6961 ,sum(CAST(street0_FoldTo4BDone as integer))
6962 ,sum(CAST(street0_SqueezeChance as integer))
6963 ,sum(CAST(street0_SqueezeDone as integer))
6964 ,sum(CAST(raiseToStealChance as integer))
6965 ,sum(CAST(raiseToStealDone as integer))
6966 ,sum(CAST(stealChance as integer))
6967 ,sum(CAST(stealDone as integer))
6968 ,sum(CAST(success_Steal as integer))
6969 ,sum(CAST(street1Seen as integer))
6970 ,sum(CAST(street2Seen as integer))
6971 ,sum(CAST(street3Seen as integer))
6972 ,sum(CAST(street4Seen as integer))
6973 ,sum(CAST(sawShowdown as integer))
6974 ,sum(CAST(street1Aggr as integer))
6975 ,sum(CAST(street2Aggr as integer))
6976 ,sum(CAST(street3Aggr as integer))
6977 ,sum(CAST(street4Aggr as integer))
6978 ,sum(CAST(otherRaisedStreet0 as integer))
6979 ,sum(CAST(otherRaisedStreet1 as integer))
6980 ,sum(CAST(otherRaisedStreet2 as integer))
6981 ,sum(CAST(otherRaisedStreet3 as integer))
6982 ,sum(CAST(otherRaisedStreet4 as integer))
6983 ,sum(CAST(foldToOtherRaisedStreet0 as integer))
6984 ,sum(CAST(foldToOtherRaisedStreet1 as integer))
6985 ,sum(CAST(foldToOtherRaisedStreet2 as integer))
6986 ,sum(CAST(foldToOtherRaisedStreet3 as integer))
6987 ,sum(CAST(foldToOtherRaisedStreet4 as integer))
6988 ,sum(CAST(wonWhenSeenStreet1 as integer))
6989 ,sum(CAST(wonWhenSeenStreet2 as integer))
6990 ,sum(CAST(wonWhenSeenStreet3 as integer))
6991 ,sum(CAST(wonWhenSeenStreet4 as integer))
6992 ,sum(CAST(wonAtSD as integer))
6993 ,sum(CAST(raiseFirstInChance as integer))
6994 ,sum(CAST(raisedFirstIn as integer))
6995 ,sum(CAST(foldBbToStealChance as integer))
6996 ,sum(CAST(foldedBbToSteal as integer))
6997 ,sum(CAST(foldSbToStealChance as integer))
6998 ,sum(CAST(foldedSbToSteal as integer))
6999 ,sum(CAST(street1CBChance as integer))
7000 ,sum(CAST(street1CBDone as integer))
7001 ,sum(CAST(street2CBChance as integer))
7002 ,sum(CAST(street2CBDone as integer))
7003 ,sum(CAST(street3CBChance as integer))
7004 ,sum(CAST(street3CBDone as integer))
7005 ,sum(CAST(street4CBChance as integer))
7006 ,sum(CAST(street4CBDone as integer))
7007 ,sum(CAST(foldToStreet1CBChance as integer))
7008 ,sum(CAST(foldToStreet1CBDone as integer))
7009 ,sum(CAST(foldToStreet2CBChance as integer))
7010 ,sum(CAST(foldToStreet2CBDone as integer))
7011 ,sum(CAST(foldToStreet3CBChance as integer))
7012 ,sum(CAST(foldToStreet3CBDone as integer))
7013 ,sum(CAST(foldToStreet4CBChance as integer))
7014 ,sum(CAST(foldToStreet4CBDone as integer))
7015 ,sum(CAST(common as integer))
7016 ,sum(CAST(committed as integer))
7017 ,sum(CAST(winnings as integer))
7018 ,sum(CAST(rake as integer))
7019 ,sum(CAST(rakeDealt as integer))
7020 ,sum(CAST(rakeContributed as integer))
7021 ,sum(CAST(rakeWeighted as integer))
7022 ,sum(CAST(totalProfit as integer))
7023 ,sum(allInEV)
7024 ,sum(CAST(case when sawShowdown = 1 then totalProfit else 0 end as integer))
7025 ,sum(CAST(case when sawShowdown = 0 then totalProfit else 0 end as integer))
7026 ,sum(CAST(street1CheckCallRaiseChance as integer))
7027 ,sum(CAST(street1CheckCallDone as integer))
7028 ,sum(CAST(street1CheckRaiseDone as integer))
7029 ,sum(CAST(street2CheckCallRaiseChance as integer))
7030 ,sum(CAST(street2CheckCallDone as integer))
7031 ,sum(CAST(street2CheckRaiseDone as integer))
7032 ,sum(CAST(street3CheckCallRaiseChance as integer))
7033 ,sum(CAST(street3CheckCallDone as integer))
7034 ,sum(CAST(street3CheckRaiseDone as integer))
7035 ,sum(CAST(street4CheckCallRaiseChance as integer))
7036 ,sum(CAST(street4CheckCallDone as integer))
7037 ,sum(CAST(street4CheckRaiseDone as integer))
7038 ,sum(CAST(street0Calls as integer))
7039 ,sum(CAST(street1Calls as integer))
7040 ,sum(CAST(street2Calls as integer))
7041 ,sum(CAST(street3Calls as integer))
7042 ,sum(CAST(street4Calls as integer))
7043 ,sum(CAST(street0Bets as integer))
7044 ,sum(CAST(street1Bets as integer))
7045 ,sum(CAST(street2Bets as integer))
7046 ,sum(CAST(street3Bets as integer))
7047 ,sum(CAST(street4Bets as integer))
7048 ,sum(CAST(hp.street0Raises as integer))
7049 ,sum(CAST(hp.street1Raises as integer))
7050 ,sum(CAST(hp.street2Raises as integer))
7051 ,sum(CAST(hp.street3Raises as integer))
7052 ,sum(CAST(hp.street4Raises as integer))
7053 ,sum(CAST(street1Discards as integer))
7054 ,sum(CAST(street2Discards as integer))
7055 ,sum(CAST(street3Discards as integer))
7056 FROM Hands h
7057 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>)
7058 INNER JOIN Gametypes g ON (h.gametypeId = g.id)
7059 <sessions_join_clause>
7060 <tourney_join_clause>
7061 <where_clause>
7062 GROUP BY <group>
7063"""
7066 self.query['insert_hudcache'] = """insert into HudCache (
7067 gametypeId,
7068 playerId,
7069 seats,
7070 position,
7071 tourneyTypeId,
7072 styleKey,
7073 n,
7074 street0VPIChance,
7075 street0VPI,
7076 street0AggrChance,
7077 street0Aggr,
7078 street0CalledRaiseChance,
7079 street0CalledRaiseDone,
7080 street0_2BChance,
7081 street0_2BDone,
7082 street0_3BChance,
7083 street0_3BDone,
7084 street0_4BChance,
7085 street0_4BDone,
7086 street0_C4BChance,
7087 street0_C4BDone,
7088 street0_FoldTo2BChance,
7089 street0_FoldTo2BDone,
7090 street0_FoldTo3BChance,
7091 street0_FoldTo3BDone,
7092 street0_FoldTo4BChance,
7093 street0_FoldTo4BDone,
7094 street0_SqueezeChance,
7095 street0_SqueezeDone,
7096 raiseToStealChance,
7097 raiseToStealDone,
7098 stealChance,
7099 stealDone,
7100 success_Steal,
7101 street1Seen,
7102 street2Seen,
7103 street3Seen,
7104 street4Seen,
7105 sawShowdown,
7106 street1Aggr,
7107 street2Aggr,
7108 street3Aggr,
7109 street4Aggr,
7110 otherRaisedStreet0,
7111 otherRaisedStreet1,
7112 otherRaisedStreet2,
7113 otherRaisedStreet3,
7114 otherRaisedStreet4,
7115 foldToOtherRaisedStreet0,
7116 foldToOtherRaisedStreet1,
7117 foldToOtherRaisedStreet2,
7118 foldToOtherRaisedStreet3,
7119 foldToOtherRaisedStreet4,
7120 wonWhenSeenStreet1,
7121 wonWhenSeenStreet2,
7122 wonWhenSeenStreet3,
7123 wonWhenSeenStreet4,
7124 wonAtSD,
7125 raiseFirstInChance,
7126 raisedFirstIn,
7127 foldBbToStealChance,
7128 foldedBbToSteal,
7129 foldSbToStealChance,
7130 foldedSbToSteal,
7131 street1CBChance,
7132 street1CBDone,
7133 street2CBChance,
7134 street2CBDone,
7135 street3CBChance,
7136 street3CBDone,
7137 street4CBChance,
7138 street4CBDone,
7139 foldToStreet1CBChance,
7140 foldToStreet1CBDone,
7141 foldToStreet2CBChance,
7142 foldToStreet2CBDone,
7143 foldToStreet3CBChance,
7144 foldToStreet3CBDone,
7145 foldToStreet4CBChance,
7146 foldToStreet4CBDone,
7147 common,
7148 committed,
7149 winnings,
7150 rake,
7151 rakeDealt,
7152 rakeContributed,
7153 rakeWeighted,
7154 totalProfit,
7155 allInEV,
7156 showdownWinnings,
7157 nonShowdownWinnings,
7158 street1CheckCallRaiseChance,
7159 street1CheckCallDone,
7160 street1CheckRaiseDone,
7161 street2CheckCallRaiseChance,
7162 street2CheckCallDone,
7163 street2CheckRaiseDone,
7164 street3CheckCallRaiseChance,
7165 street3CheckCallDone,
7166 street3CheckRaiseDone,
7167 street4CheckCallRaiseChance,
7168 street4CheckCallDone,
7169 street4CheckRaiseDone,
7170 street0Calls,
7171 street1Calls,
7172 street2Calls,
7173 street3Calls,
7174 street4Calls,
7175 street0Bets,
7176 street1Bets,
7177 street2Bets,
7178 street3Bets,
7179 street4Bets,
7180 street0Raises,
7181 street1Raises,
7182 street2Raises,
7183 street3Raises,
7184 street4Raises,
7185 street1Discards,
7186 street2Discards,
7187 street3Discards)
7188 values (%s, %s, %s, %s, %s,
7189 %s, %s, %s, %s, %s,
7190 %s, %s, %s, %s, %s,
7191 %s, %s, %s, %s, %s,
7192 %s, %s, %s, %s, %s,
7193 %s, %s, %s, %s, %s,
7194 %s, %s, %s, %s, %s,
7195 %s, %s, %s, %s, %s,
7196 %s, %s, %s, %s, %s,
7197 %s, %s, %s, %s, %s,
7198 %s, %s, %s, %s, %s,
7199 %s, %s, %s, %s, %s,
7200 %s, %s, %s, %s, %s,
7201 %s, %s, %s, %s, %s,
7202 %s, %s, %s, %s, %s,
7203 %s, %s, %s, %s, %s,
7204 %s, %s, %s, %s, %s,
7205 %s, %s, %s, %s, %s,
7206 %s, %s, %s, %s, %s,
7207 %s, %s, %s, %s, %s,
7208 %s, %s, %s, %s, %s,
7209 %s, %s, %s, %s, %s,
7210 %s, %s, %s, %s, %s,
7211 %s, %s, %s, %s, %s,
7212 %s)"""
7214 self.query['update_hudcache'] = """
7215 UPDATE HudCache SET
7216 n=n+%s,
7217 street0VPIChance=street0VPIChance+%s,
7218 street0VPI=street0VPI+%s,
7219 street0AggrChance=street0AggrChance+%s,
7220 street0Aggr=street0Aggr+%s,
7221 street0CalledRaiseChance=street0CalledRaiseChance+%s,
7222 street0CalledRaiseDone=street0CalledRaiseDone+%s,
7223 street0_2BChance=street0_2BChance+%s,
7224 street0_2BDone=street0_2BDone+%s,
7225 street0_3BChance=street0_3BChance+%s,
7226 street0_3BDone=street0_3BDone+%s,
7227 street0_4BChance=street0_4BChance+%s,
7228 street0_4BDone=street0_4BDone+%s,
7229 street0_C4BChance=street0_C4BChance+%s,
7230 street0_C4BDone=street0_C4BDone+%s,
7231 street0_FoldTo2BChance=street0_FoldTo2BChance+%s,
7232 street0_FoldTo2BDone=street0_FoldTo2BDone+%s,
7233 street0_FoldTo3BChance=street0_FoldTo3BChance+%s,
7234 street0_FoldTo3BDone=street0_FoldTo3BDone+%s,
7235 street0_FoldTo4BChance=street0_FoldTo4BChance+%s,
7236 street0_FoldTo4BDone=street0_FoldTo4BDone+%s,
7237 street0_SqueezeChance=street0_SqueezeChance+%s,
7238 street0_SqueezeDone=street0_SqueezeDone+%s,
7239 raiseToStealChance=raiseToStealChance+%s,
7240 raiseToStealDone=raiseToStealDone+%s,
7241 stealChance=stealChance+%s,
7242 stealDone=stealDone+%s,
7243 success_Steal=success_Steal+%s,
7244 street1Seen=street1Seen+%s,
7245 street2Seen=street2Seen+%s,
7246 street3Seen=street3Seen+%s,
7247 street4Seen=street4Seen+%s,
7248 sawShowdown=sawShowdown+%s,
7249 street1Aggr=street1Aggr+%s,
7250 street2Aggr=street2Aggr+%s,
7251 street3Aggr=street3Aggr+%s,
7252 street4Aggr=street4Aggr+%s,
7253 otherRaisedStreet0=otherRaisedStreet0+%s,
7254 otherRaisedStreet1=otherRaisedStreet1+%s,
7255 otherRaisedStreet2=otherRaisedStreet2+%s,
7256 otherRaisedStreet3=otherRaisedStreet3+%s,
7257 otherRaisedStreet4=otherRaisedStreet4+%s,
7258 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s,
7259 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s,
7260 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s,
7261 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s,
7262 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s,
7263 wonWhenSeenStreet1=wonWhenSeenStreet1+%s,
7264 wonWhenSeenStreet2=wonWhenSeenStreet2+%s,
7265 wonWhenSeenStreet3=wonWhenSeenStreet3+%s,
7266 wonWhenSeenStreet4=wonWhenSeenStreet4+%s,
7267 wonAtSD=wonAtSD+%s,
7268 raiseFirstInChance=raiseFirstInChance+%s,
7269 raisedFirstIn=raisedFirstIn+%s,
7270 foldBbToStealChance=foldBbToStealChance+%s,
7271 foldedBbToSteal=foldedBbToSteal+%s,
7272 foldSbToStealChance=foldSbToStealChance+%s,
7273 foldedSbToSteal=foldedSbToSteal+%s,
7274 street1CBChance=street1CBChance+%s,
7275 street1CBDone=street1CBDone+%s,
7276 street2CBChance=street2CBChance+%s,
7277 street2CBDone=street2CBDone+%s,
7278 street3CBChance=street3CBChance+%s,
7279 street3CBDone=street3CBDone+%s,
7280 street4CBChance=street4CBChance+%s,
7281 street4CBDone=street4CBDone+%s,
7282 foldToStreet1CBChance=foldToStreet1CBChance+%s,
7283 foldToStreet1CBDone=foldToStreet1CBDone+%s,
7284 foldToStreet2CBChance=foldToStreet2CBChance+%s,
7285 foldToStreet2CBDone=foldToStreet2CBDone+%s,
7286 foldToStreet3CBChance=foldToStreet3CBChance+%s,
7287 foldToStreet3CBDone=foldToStreet3CBDone+%s,
7288 foldToStreet4CBChance=foldToStreet4CBChance+%s,
7289 foldToStreet4CBDone=foldToStreet4CBDone+%s,
7290 common=common+%s,
7291 committed=committed+%s,
7292 winnings=winnings+%s,
7293 rake=rake+%s,
7294 rakeDealt=rakeDealt+%s,
7295 rakeContributed=rakeContributed+%s,
7296 rakeWeighted=rakeWeighted+%s,
7297 totalProfit=totalProfit+%s,
7298 allInEV=allInEV+%s,
7299 showdownWinnings=showdownWinnings+%s,
7300 nonShowdownWinnings=nonShowdownWinnings+%s,
7301 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s,
7302 street1CheckCallDone=street1CheckCallDone+%s,
7303 street1CheckRaiseDone=street1CheckRaiseDone+%s,
7304 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s,
7305 street2CheckCallDone=street2CheckCallDone+%s,
7306 street2CheckRaiseDone=street2CheckRaiseDone+%s,
7307 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s,
7308 street3CheckCallDone=street3CheckCallDone+%s,
7309 street3CheckRaiseDone=street3CheckRaiseDone+%s,
7310 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s,
7311 street4CheckCallDone=street4CheckCallDone+%s,
7312 street4CheckRaiseDone=street4CheckRaiseDone+%s,
7313 street0Calls=street0Calls+%s,
7314 street1Calls=street1Calls+%s,
7315 street2Calls=street2Calls+%s,
7316 street3Calls=street3Calls+%s,
7317 street4Calls=street4Calls+%s,
7318 street0Bets=street0Bets+%s,
7319 street1Bets=street1Bets+%s,
7320 street2Bets=street2Bets+%s,
7321 street3Bets=street3Bets+%s,
7322 street4Bets=street4Bets+%s,
7323 street0Raises=street0Raises+%s,
7324 street1Raises=street1Raises+%s,
7325 street2Raises=street2Raises+%s,
7326 street3Raises=street3Raises+%s,
7327 street4Raises=street4Raises+%s,
7328 street1Discards=street1Discards+%s,
7329 street2Discards=street2Discards+%s,
7330 street3Discards=street3Discards+%s
7331 WHERE id=%s"""
7333 self.query['select_hudcache_ring'] = """
7334 SELECT id
7335 FROM HudCache
7336 WHERE gametypeId=%s
7337 AND playerId=%s
7338 AND seats=%s
7339 AND position=%s
7340 AND tourneyTypeId is NULL
7341 AND styleKey = %s"""
7343 self.query['select_hudcache_tour'] = """
7344 SELECT id
7345 FROM HudCache
7346 WHERE gametypeId=%s
7347 AND playerId=%s
7348 AND seats=%s
7349 AND position=%s
7350 AND tourneyTypeId=%s
7351 AND styleKey = %s"""
7353 self.query['get_hero_hudcache_start'] = """select min(hc.styleKey)
7354 from HudCache hc
7355 where hc.playerId in <playerid_list>
7356 and hc.styleKey like 'd%'"""
7358 ####################################
7359 # Queries to insert/update cardscache
7360 ####################################
7362 self.query['insert_cardscache'] = """insert into CardsCache (
7363 weekId,
7364 monthId,
7365 gametypeId,
7366 tourneyTypeId,
7367 playerId,
7368 startCards,
7369 n,
7370 street0VPIChance,
7371 street0VPI,
7372 street0AggrChance,
7373 street0Aggr,
7374 street0CalledRaiseChance,
7375 street0CalledRaiseDone,
7376 street0_3BChance,
7377 street0_3BDone,
7378 street0_2BChance,
7379 street0_2BDone,
7380 street0_4BChance,
7381 street0_4BDone,
7382 street0_C4BChance,
7383 street0_C4BDone,
7384 street0_FoldTo2BChance,
7385 street0_FoldTo2BDone,
7386 street0_FoldTo3BChance,
7387 street0_FoldTo3BDone,
7388 street0_FoldTo4BChance,
7389 street0_FoldTo4BDone,
7390 street0_SqueezeChance,
7391 street0_SqueezeDone,
7392 raiseToStealChance,
7393 raiseToStealDone,
7394 stealChance,
7395 stealDone,
7396 success_Steal,
7397 street1Seen,
7398 street2Seen,
7399 street3Seen,
7400 street4Seen,
7401 sawShowdown,
7402 street1Aggr,
7403 street2Aggr,
7404 street3Aggr,
7405 street4Aggr,
7406 otherRaisedStreet0,
7407 otherRaisedStreet1,
7408 otherRaisedStreet2,
7409 otherRaisedStreet3,
7410 otherRaisedStreet4,
7411 foldToOtherRaisedStreet0,
7412 foldToOtherRaisedStreet1,
7413 foldToOtherRaisedStreet2,
7414 foldToOtherRaisedStreet3,
7415 foldToOtherRaisedStreet4,
7416 wonWhenSeenStreet1,
7417 wonWhenSeenStreet2,
7418 wonWhenSeenStreet3,
7419 wonWhenSeenStreet4,
7420 wonAtSD,
7421 raiseFirstInChance,
7422 raisedFirstIn,
7423 foldBbToStealChance,
7424 foldedBbToSteal,
7425 foldSbToStealChance,
7426 foldedSbToSteal,
7427 street1CBChance,
7428 street1CBDone,
7429 street2CBChance,
7430 street2CBDone,
7431 street3CBChance,
7432 street3CBDone,
7433 street4CBChance,
7434 street4CBDone,
7435 foldToStreet1CBChance,
7436 foldToStreet1CBDone,
7437 foldToStreet2CBChance,
7438 foldToStreet2CBDone,
7439 foldToStreet3CBChance,
7440 foldToStreet3CBDone,
7441 foldToStreet4CBChance,
7442 foldToStreet4CBDone,
7443 common,
7444 committed,
7445 winnings,
7446 rake,
7447 rakeDealt,
7448 rakeContributed,
7449 rakeWeighted,
7450 totalProfit,
7451 allInEV,
7452 showdownWinnings,
7453 nonShowdownWinnings,
7454 street1CheckCallRaiseChance,
7455 street1CheckCallDone,
7456 street1CheckRaiseDone,
7457 street2CheckCallRaiseChance,
7458 street2CheckCallDone,
7459 street2CheckRaiseDone,
7460 street3CheckCallRaiseChance,
7461 street3CheckCallDone,
7462 street3CheckRaiseDone,
7463 street4CheckCallRaiseChance,
7464 street4CheckCallDone,
7465 street4CheckRaiseDone,
7466 street0Calls,
7467 street1Calls,
7468 street2Calls,
7469 street3Calls,
7470 street4Calls,
7471 street0Bets,
7472 street1Bets,
7473 street2Bets,
7474 street3Bets,
7475 street4Bets,
7476 street0Raises,
7477 street1Raises,
7478 street2Raises,
7479 street3Raises,
7480 street4Raises,
7481 street1Discards,
7482 street2Discards,
7483 street3Discards)
7484 values (%s, %s, %s, %s, %s,
7485 %s, %s, %s, %s, %s,
7486 %s, %s, %s, %s, %s,
7487 %s, %s, %s, %s, %s,
7488 %s, %s, %s, %s, %s,
7489 %s, %s, %s, %s, %s,
7490 %s, %s, %s, %s, %s,
7491 %s, %s, %s, %s, %s,
7492 %s, %s, %s, %s, %s,
7493 %s, %s, %s, %s, %s,
7494 %s, %s, %s, %s, %s,
7495 %s, %s, %s, %s, %s,
7496 %s, %s, %s, %s, %s,
7497 %s, %s, %s, %s, %s,
7498 %s, %s, %s, %s, %s,
7499 %s, %s, %s, %s, %s,
7500 %s, %s, %s, %s, %s,
7501 %s, %s, %s, %s, %s,
7502 %s, %s, %s, %s, %s,
7503 %s, %s, %s, %s, %s,
7504 %s, %s, %s, %s, %s,
7505 %s, %s, %s, %s, %s,
7506 %s, %s, %s, %s, %s,
7507 %s, %s, %s, %s, %s,
7508 %s)"""
7510 self.query['update_cardscache'] = """
7511 UPDATE CardsCache SET
7512 n=n+%s,
7513 street0VPIChance=street0VPIChance+%s,
7514 street0VPI=street0VPI+%s,
7515 street0AggrChance=street0AggrChance+%s,
7516 street0Aggr=street0Aggr+%s,
7517 street0CalledRaiseChance=street0CalledRaiseChance+%s,
7518 street0CalledRaiseDone=street0CalledRaiseDone+%s,
7519 street0_2BChance=street0_2BChance+%s,
7520 street0_2BDone=street0_2BDone+%s,
7521 street0_3BChance=street0_3BChance+%s,
7522 street0_3BDone=street0_3BDone+%s,
7523 street0_4BChance=street0_4BChance+%s,
7524 street0_4BDone=street0_4BDone+%s,
7525 street0_C4BChance=street0_C4BChance+%s,
7526 street0_C4BDone=street0_C4BDone+%s,
7527 street0_FoldTo2BChance=street0_FoldTo2BChance+%s,
7528 street0_FoldTo2BDone=street0_FoldTo2BDone+%s,
7529 street0_FoldTo3BChance=street0_FoldTo3BChance+%s,
7530 street0_FoldTo3BDone=street0_FoldTo3BDone+%s,
7531 street0_FoldTo4BChance=street0_FoldTo4BChance+%s,
7532 street0_FoldTo4BDone=street0_FoldTo4BDone+%s,
7533 street0_SqueezeChance=street0_SqueezeChance+%s,
7534 street0_SqueezeDone=street0_SqueezeDone+%s,
7535 raiseToStealChance=raiseToStealChance+%s,
7536 raiseToStealDone=raiseToStealDone+%s,
7537 stealChance=stealChance+%s,
7538 stealDone=stealDone+%s,
7539 success_Steal=success_Steal+%s,
7540 street1Seen=street1Seen+%s,
7541 street2Seen=street2Seen+%s,
7542 street3Seen=street3Seen+%s,
7543 street4Seen=street4Seen+%s,
7544 sawShowdown=sawShowdown+%s,
7545 street1Aggr=street1Aggr+%s,
7546 street2Aggr=street2Aggr+%s,
7547 street3Aggr=street3Aggr+%s,
7548 street4Aggr=street4Aggr+%s,
7549 otherRaisedStreet0=otherRaisedStreet0+%s,
7550 otherRaisedStreet1=otherRaisedStreet1+%s,
7551 otherRaisedStreet2=otherRaisedStreet2+%s,
7552 otherRaisedStreet3=otherRaisedStreet3+%s,
7553 otherRaisedStreet4=otherRaisedStreet4+%s,
7554 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s,
7555 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s,
7556 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s,
7557 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s,
7558 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s,
7559 wonWhenSeenStreet1=wonWhenSeenStreet1+%s,
7560 wonWhenSeenStreet2=wonWhenSeenStreet2+%s,
7561 wonWhenSeenStreet3=wonWhenSeenStreet3+%s,
7562 wonWhenSeenStreet4=wonWhenSeenStreet4+%s,
7563 wonAtSD=wonAtSD+%s,
7564 raiseFirstInChance=raiseFirstInChance+%s,
7565 raisedFirstIn=raisedFirstIn+%s,
7566 foldBbToStealChance=foldBbToStealChance+%s,
7567 foldedBbToSteal=foldedBbToSteal+%s,
7568 foldSbToStealChance=foldSbToStealChance+%s,
7569 foldedSbToSteal=foldedSbToSteal+%s,
7570 street1CBChance=street1CBChance+%s,
7571 street1CBDone=street1CBDone+%s,
7572 street2CBChance=street2CBChance+%s,
7573 street2CBDone=street2CBDone+%s,
7574 street3CBChance=street3CBChance+%s,
7575 street3CBDone=street3CBDone+%s,
7576 street4CBChance=street4CBChance+%s,
7577 street4CBDone=street4CBDone+%s,
7578 foldToStreet1CBChance=foldToStreet1CBChance+%s,
7579 foldToStreet1CBDone=foldToStreet1CBDone+%s,
7580 foldToStreet2CBChance=foldToStreet2CBChance+%s,
7581 foldToStreet2CBDone=foldToStreet2CBDone+%s,
7582 foldToStreet3CBChance=foldToStreet3CBChance+%s,
7583 foldToStreet3CBDone=foldToStreet3CBDone+%s,
7584 foldToStreet4CBChance=foldToStreet4CBChance+%s,
7585 foldToStreet4CBDone=foldToStreet4CBDone+%s,
7586 common=common+%s,
7587 committed=committed+%s,
7588 winnings=winnings+%s,
7589 rake=rake+%s,
7590 rakeDealt=rakeDealt+%s,
7591 rakeContributed=rakeContributed+%s,
7592 rakeWeighted=rakeWeighted+%s,
7593 totalProfit=totalProfit+%s,
7594 allInEV=allInEV+%s,
7595 showdownWinnings=showdownWinnings+%s,
7596 nonShowdownWinnings=nonShowdownWinnings+%s,
7597 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s,
7598 street1CheckCallDone=street1CheckCallDone+%s,
7599 street1CheckRaiseDone=street1CheckRaiseDone+%s,
7600 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s,
7601 street2CheckCallDone=street2CheckCallDone+%s,
7602 street2CheckRaiseDone=street2CheckRaiseDone+%s,
7603 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s,
7604 street3CheckCallDone=street3CheckCallDone+%s,
7605 street3CheckRaiseDone=street3CheckRaiseDone+%s,
7606 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s,
7607 street4CheckCallDone=street4CheckCallDone+%s,
7608 street4CheckRaiseDone=street4CheckRaiseDone+%s,
7609 street0Calls=street0Calls+%s,
7610 street1Calls=street1Calls+%s,
7611 street2Calls=street2Calls+%s,
7612 street3Calls=street3Calls+%s,
7613 street4Calls=street4Calls+%s,
7614 street0Bets=street0Bets+%s,
7615 street1Bets=street1Bets+%s,
7616 street2Bets=street2Bets+%s,
7617 street3Bets=street3Bets+%s,
7618 street4Bets=street4Bets+%s,
7619 street0Raises=street0Raises+%s,
7620 street1Raises=street1Raises+%s,
7621 street2Raises=street2Raises+%s,
7622 street3Raises=street3Raises+%s,
7623 street4Raises=street4Raises+%s,
7624 street1Discards=street1Discards+%s,
7625 street2Discards=street2Discards+%s,
7626 street3Discards=street3Discards+%s
7627 WHERE id=%s"""
7629 self.query['select_cardscache_ring'] = """
7630 SELECT id
7631 FROM CardsCache
7632 WHERE weekId=%s
7633 AND monthId=%s
7634 AND gametypeId=%s
7635 AND tourneyTypeId is NULL
7636 AND playerId=%s
7637 AND startCards=%s"""
7639 self.query['select_cardscache_tour'] = """
7640 SELECT id
7641 FROM CardsCache
7642 WHERE weekId=%s
7643 AND monthId=%s
7644 AND gametypeId=%s
7645 AND tourneyTypeId=%s
7646 AND playerId=%s
7647 AND startCards=%s"""
7650 ####################################
7651 # create comment on players
7652 ####################################
7654 self.query['get_player_comment'] = """
7655 SELECT comment FROM Players WHERE id=%s
7656 """
7658 self.query['update_player_comment'] = """
7659 UPDATE Players SET comment=%s, commentTs=CURRENT_TIMESTAMP WHERE id=%s
7660 """
7661 self.query['get_player_name'] = "SELECT name FROM Players WHERE id=%s"
7663 ####################################
7665 ####################################
7666 # Queries to insert/update positionscache
7667 ####################################
7669 self.query['insert_positionscache'] = """insert into PositionsCache (
7670 weekId,
7671 monthId,
7672 gametypeId,
7673 tourneyTypeId,
7674 playerId,
7675 seats,
7676 maxPosition,
7677 position,
7678 n,
7679 street0VPIChance,
7680 street0VPI,
7681 street0AggrChance,
7682 street0Aggr,
7683 street0CalledRaiseChance,
7684 street0CalledRaiseDone,
7685 street0_2BChance,
7686 street0_2BDone,
7687 street0_3BChance,
7688 street0_3BDone,
7689 street0_4BChance,
7690 street0_4BDone,
7691 street0_C4BChance,
7692 street0_C4BDone,
7693 street0_FoldTo2BChance,
7694 street0_FoldTo2BDone,
7695 street0_FoldTo3BChance,
7696 street0_FoldTo3BDone,
7697 street0_FoldTo4BChance,
7698 street0_FoldTo4BDone,
7699 street0_SqueezeChance,
7700 street0_SqueezeDone,
7701 raiseToStealChance,
7702 raiseToStealDone,
7703 stealChance,
7704 stealDone,
7705 success_Steal,
7706 street1Seen,
7707 street2Seen,
7708 street3Seen,
7709 street4Seen,
7710 sawShowdown,
7711 street1Aggr,
7712 street2Aggr,
7713 street3Aggr,
7714 street4Aggr,
7715 otherRaisedStreet0,
7716 otherRaisedStreet1,
7717 otherRaisedStreet2,
7718 otherRaisedStreet3,
7719 otherRaisedStreet4,
7720 foldToOtherRaisedStreet0,
7721 foldToOtherRaisedStreet1,
7722 foldToOtherRaisedStreet2,
7723 foldToOtherRaisedStreet3,
7724 foldToOtherRaisedStreet4,
7725 wonWhenSeenStreet1,
7726 wonWhenSeenStreet2,
7727 wonWhenSeenStreet3,
7728 wonWhenSeenStreet4,
7729 wonAtSD,
7730 raiseFirstInChance,
7731 raisedFirstIn,
7732 foldBbToStealChance,
7733 foldedBbToSteal,
7734 foldSbToStealChance,
7735 foldedSbToSteal,
7736 street1CBChance,
7737 street1CBDone,
7738 street2CBChance,
7739 street2CBDone,
7740 street3CBChance,
7741 street3CBDone,
7742 street4CBChance,
7743 street4CBDone,
7744 foldToStreet1CBChance,
7745 foldToStreet1CBDone,
7746 foldToStreet2CBChance,
7747 foldToStreet2CBDone,
7748 foldToStreet3CBChance,
7749 foldToStreet3CBDone,
7750 foldToStreet4CBChance,
7751 foldToStreet4CBDone,
7752 common,
7753 committed,
7754 winnings,
7755 rake,
7756 rakeDealt,
7757 rakeContributed,
7758 rakeWeighted,
7759 totalProfit,
7760 allInEV,
7761 showdownWinnings,
7762 nonShowdownWinnings,
7763 street1CheckCallRaiseChance,
7764 street1CheckCallDone,
7765 street1CheckRaiseDone,
7766 street2CheckCallRaiseChance,
7767 street2CheckCallDone,
7768 street2CheckRaiseDone,
7769 street3CheckCallRaiseChance,
7770 street3CheckCallDone,
7771 street3CheckRaiseDone,
7772 street4CheckCallRaiseChance,
7773 street4CheckCallDone,
7774 street4CheckRaiseDone,
7775 street0Calls,
7776 street1Calls,
7777 street2Calls,
7778 street3Calls,
7779 street4Calls,
7780 street0Bets,
7781 street1Bets,
7782 street2Bets,
7783 street3Bets,
7784 street4Bets,
7785 street0Raises,
7786 street1Raises,
7787 street2Raises,
7788 street3Raises,
7789 street4Raises,
7790 street1Discards,
7791 street2Discards,
7792 street3Discards)
7793 values (%s, %s, %s, %s, %s,
7794 %s, %s, %s, %s, %s,
7795 %s, %s, %s, %s, %s,
7796 %s, %s, %s, %s, %s,
7797 %s, %s, %s, %s, %s,
7798 %s, %s, %s, %s, %s,
7799 %s, %s, %s, %s, %s,
7800 %s, %s, %s, %s, %s,
7801 %s, %s, %s, %s, %s,
7802 %s, %s, %s, %s, %s,
7803 %s, %s, %s, %s, %s,
7804 %s, %s, %s, %s, %s,
7805 %s, %s, %s, %s, %s,
7806 %s, %s, %s, %s, %s,
7807 %s, %s, %s, %s, %s,
7808 %s, %s, %s, %s, %s,
7809 %s, %s, %s, %s, %s,
7810 %s, %s, %s, %s, %s,
7811 %s, %s, %s, %s, %s,
7812 %s, %s, %s, %s, %s,
7813 %s, %s, %s, %s, %s,
7814 %s, %s, %s, %s, %s,
7815 %s, %s, %s, %s, %s,
7816 %s, %s, %s, %s, %s,
7817 %s, %s, %s
7818 )"""
7820 self.query['update_positionscache'] = """
7821 UPDATE PositionsCache SET
7822 n=n+%s,
7823 street0VPIChance=street0VPIChance+%s,
7824 street0VPI=street0VPI+%s,
7825 street0AggrChance=street0AggrChance+%s,
7826 street0Aggr=street0Aggr+%s,
7827 street0CalledRaiseChance=street0CalledRaiseChance+%s,
7828 street0CalledRaiseDone=street0CalledRaiseDone+%s,
7829 street0_2BChance=street0_2BChance+%s,
7830 street0_2BDone=street0_2BDone+%s,
7831 street0_3BChance=street0_3BChance+%s,
7832 street0_3BDone=street0_3BDone+%s,
7833 street0_4BChance=street0_4BChance+%s,
7834 street0_4BDone=street0_4BDone+%s,
7835 street0_C4BChance=street0_C4BChance+%s,
7836 street0_C4BDone=street0_C4BDone+%s,
7837 street0_FoldTo2BChance=street0_FoldTo2BChance+%s,
7838 street0_FoldTo2BDone=street0_FoldTo2BDone+%s,
7839 street0_FoldTo3BChance=street0_FoldTo3BChance+%s,
7840 street0_FoldTo3BDone=street0_FoldTo3BDone+%s,
7841 street0_FoldTo4BChance=street0_FoldTo4BChance+%s,
7842 street0_FoldTo4BDone=street0_FoldTo4BDone+%s,
7843 street0_SqueezeChance=street0_SqueezeChance+%s,
7844 street0_SqueezeDone=street0_SqueezeDone+%s,
7845 raiseToStealChance=raiseToStealChance+%s,
7846 raiseToStealDone=raiseToStealDone+%s,
7847 stealChance=stealChance+%s,
7848 stealDone=stealDone+%s,
7849 success_Steal=success_Steal+%s,
7850 street1Seen=street1Seen+%s,
7851 street2Seen=street2Seen+%s,
7852 street3Seen=street3Seen+%s,
7853 street4Seen=street4Seen+%s,
7854 sawShowdown=sawShowdown+%s,
7855 street1Aggr=street1Aggr+%s,
7856 street2Aggr=street2Aggr+%s,
7857 street3Aggr=street3Aggr+%s,
7858 street4Aggr=street4Aggr+%s,
7859 otherRaisedStreet0=otherRaisedStreet0+%s,
7860 otherRaisedStreet1=otherRaisedStreet1+%s,
7861 otherRaisedStreet2=otherRaisedStreet2+%s,
7862 otherRaisedStreet3=otherRaisedStreet3+%s,
7863 otherRaisedStreet4=otherRaisedStreet4+%s,
7864 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s,
7865 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s,
7866 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s,
7867 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s,
7868 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s,
7869 wonWhenSeenStreet1=wonWhenSeenStreet1+%s,
7870 wonWhenSeenStreet2=wonWhenSeenStreet2+%s,
7871 wonWhenSeenStreet3=wonWhenSeenStreet3+%s,
7872 wonWhenSeenStreet4=wonWhenSeenStreet4+%s,
7873 wonAtSD=wonAtSD+%s,
7874 raiseFirstInChance=raiseFirstInChance+%s,
7875 raisedFirstIn=raisedFirstIn+%s,
7876 foldBbToStealChance=foldBbToStealChance+%s,
7877 foldedBbToSteal=foldedBbToSteal+%s,
7878 foldSbToStealChance=foldSbToStealChance+%s,
7879 foldedSbToSteal=foldedSbToSteal+%s,
7880 street1CBChance=street1CBChance+%s,
7881 street1CBDone=street1CBDone+%s,
7882 street2CBChance=street2CBChance+%s,
7883 street2CBDone=street2CBDone+%s,
7884 street3CBChance=street3CBChance+%s,
7885 street3CBDone=street3CBDone+%s,
7886 street4CBChance=street4CBChance+%s,
7887 street4CBDone=street4CBDone+%s,
7888 foldToStreet1CBChance=foldToStreet1CBChance+%s,
7889 foldToStreet1CBDone=foldToStreet1CBDone+%s,
7890 foldToStreet2CBChance=foldToStreet2CBChance+%s,
7891 foldToStreet2CBDone=foldToStreet2CBDone+%s,
7892 foldToStreet3CBChance=foldToStreet3CBChance+%s,
7893 foldToStreet3CBDone=foldToStreet3CBDone+%s,
7894 foldToStreet4CBChance=foldToStreet4CBChance+%s,
7895 foldToStreet4CBDone=foldToStreet4CBDone+%s,
7896 common=common+%s,
7897 committed=committed+%s,
7898 winnings=winnings+%s,
7899 rake=rake+%s,
7900 rakeDealt=rakeDealt+%s,
7901 rakeContributed=rakeContributed+%s,
7902 rakeWeighted=rakeWeighted+%s,
7903 totalProfit=totalProfit+%s,
7904 allInEV=allInEV+%s,
7905 showdownWinnings=showdownWinnings+%s,
7906 nonShowdownWinnings=nonShowdownWinnings+%s,
7907 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s,
7908 street1CheckCallDone=street1CheckCallDone+%s,
7909 street1CheckRaiseDone=street1CheckRaiseDone+%s,
7910 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s,
7911 street2CheckCallDone=street2CheckCallDone+%s,
7912 street2CheckRaiseDone=street2CheckRaiseDone+%s,
7913 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s,
7914 street3CheckCallDone=street3CheckCallDone+%s,
7915 street3CheckRaiseDone=street3CheckRaiseDone+%s,
7916 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s,
7917 street4CheckCallDone=street4CheckCallDone+%s,
7918 street4CheckRaiseDone=street4CheckRaiseDone+%s,
7919 street0Calls=street0Calls+%s,
7920 street1Calls=street1Calls+%s,
7921 street2Calls=street2Calls+%s,
7922 street3Calls=street3Calls+%s,
7923 street4Calls=street4Calls+%s,
7924 street0Bets=street0Bets+%s,
7925 street1Bets=street1Bets+%s,
7926 street2Bets=street2Bets+%s,
7927 street3Bets=street3Bets+%s,
7928 street4Bets=street4Bets+%s,
7929 street0Raises=street0Raises+%s,
7930 street1Raises=street1Raises+%s,
7931 street2Raises=street2Raises+%s,
7932 street3Raises=street3Raises+%s,
7933 street4Raises=street4Raises+%s,
7934 street1Discards=street1Discards+%s,
7935 street2Discards=street2Discards+%s,
7936 street3Discards=street3Discards+%s
7937 WHERE id=%s"""
7939 self.query['select_positionscache_ring'] = """
7940 SELECT id
7941 FROM PositionsCache
7942 WHERE weekId=%s
7943 AND monthId=%s
7944 AND gametypeId=%s
7945 AND tourneyTypeId is NULL
7946 AND playerId=%s
7947 AND seats=%s
7948 AND maxPosition=%s
7949 AND position=%s"""
7951 self.query['select_positionscache_tour'] = """
7952 SELECT id
7953 FROM PositionsCache
7954 WHERE weekId=%s
7955 AND monthId=%s
7956 AND gametypeId=%s
7957 AND tourneyTypeId=%s
7958 AND playerId=%s
7959 AND seats=%s
7960 AND maxPosition=%s
7961 AND position=%s"""
7963 ####################################
7964 # Queries to rebuild/modify sessionscache
7965 ####################################
7967 self.query['clear_S_H'] = "UPDATE Hands SET sessionId = NULL"
7968 self.query['clear_S_T'] = "UPDATE Tourneys SET sessionId = NULL"
7969 self.query['clear_S_SC'] = "UPDATE SessionsCache SET sessionId = NULL"
7970 self.query['clear_S_TC'] = "UPDATE TourneysCache SET sessionId = NULL"
7971 self.query['clear_W_S'] = "UPDATE Sessions SET weekId = NULL"
7972 self.query['clear_M_S'] = "UPDATE Sessions SET monthId = NULL"
7973 self.query['clearSessionsCache'] = "DELETE FROM SessionsCache WHERE 1"
7974 self.query['clearTourneysCache'] = "DELETE FROM TourneysCache WHERE 1"
7975 self.query['clearSessions'] = "DELETE FROM Sessions WHERE 1"
7976 self.query['clearWeeks'] = "DELETE FROM Weeks WHERE 1"
7977 self.query['clearMonths'] = "DELETE FROM Months WHERE 1"
7978 self.query['update_RSC_H'] = "UPDATE Hands SET sessionId = %s WHERE id = %s"
7980 ####################################
7981 # select
7982 ####################################
7984 self.query['select_S_all'] = """
7985 SELECT SC.id as id,
7986 sessionStart,
7987 weekStart,
7988 monthStart,
7989 weekId,
7990 monthId
7991 FROM Sessions SC
7992 INNER JOIN Weeks WC ON (SC.weekId = WC.id)
7993 INNER JOIN Months MC ON (SC.monthId = MC.id)
7994 WHERE sessionEnd>=%s
7995 AND sessionStart<=%s"""
7997 self.query['select_S'] = """
7998 SELECT SC.id as id,
7999 sessionStart,
8000 sessionEnd,
8001 weekStart,
8002 monthStart,
8003 weekId,
8004 monthId
8005 FROM Sessions SC
8006 INNER JOIN Weeks WC ON (SC.weekId = WC.id)
8007 INNER JOIN Months MC ON (SC.monthId = MC.id)
8008 WHERE (sessionEnd>=%s AND sessionStart<=%s)
8009 <TOURSELECT>"""
8011 self.query['select_W'] = """
8012 SELECT id
8013 FROM Weeks
8014 WHERE weekStart = %s"""
8016 self.query['select_M'] = """
8017 SELECT id
8018 FROM Months
8019 WHERE monthStart = %s"""
8021 self.query['select_SC'] = """
8022 SELECT id,
8023 sessionId,
8024 startTime,
8025 endTime,
8026 n,
8027 street0VPIChance,
8028 street0VPI,
8029 street0AggrChance,
8030 street0Aggr,
8031 street0CalledRaiseChance,
8032 street0CalledRaiseDone,
8033 street0_2BChance,
8034 street0_2BDone,
8035 street0_3BChance,
8036 street0_3BDone,
8037 street0_4BChance,
8038 street0_4BDone,
8039 street0_C4BChance,
8040 street0_C4BDone,
8041 street0_FoldTo2BChance,
8042 street0_FoldTo2BDone,
8043 street0_FoldTo3BChance,
8044 street0_FoldTo3BDone,
8045 street0_FoldTo4BChance,
8046 street0_FoldTo4BDone,
8047 street0_SqueezeChance,
8048 street0_SqueezeDone,
8049 raiseToStealChance,
8050 raiseToStealDone,
8051 stealChance,
8052 stealDone,
8053 success_Steal,
8054 street1Seen,
8055 street2Seen,
8056 street3Seen,
8057 street4Seen,
8058 sawShowdown,
8059 street1Aggr,
8060 street2Aggr,
8061 street3Aggr,
8062 street4Aggr,
8063 otherRaisedStreet0,
8064 otherRaisedStreet1,
8065 otherRaisedStreet2,
8066 otherRaisedStreet3,
8067 otherRaisedStreet4,
8068 foldToOtherRaisedStreet0,
8069 foldToOtherRaisedStreet1,
8070 foldToOtherRaisedStreet2,
8071 foldToOtherRaisedStreet3,
8072 foldToOtherRaisedStreet4,
8073 wonWhenSeenStreet1,
8074 wonWhenSeenStreet2,
8075 wonWhenSeenStreet3,
8076 wonWhenSeenStreet4,
8077 wonAtSD,
8078 raiseFirstInChance,
8079 raisedFirstIn,
8080 foldBbToStealChance,
8081 foldedBbToSteal,
8082 foldSbToStealChance,
8083 foldedSbToSteal,
8084 street1CBChance,
8085 street1CBDone,
8086 street2CBChance,
8087 street2CBDone,
8088 street3CBChance,
8089 street3CBDone,
8090 street4CBChance,
8091 street4CBDone,
8092 foldToStreet1CBChance,
8093 foldToStreet1CBDone,
8094 foldToStreet2CBChance,
8095 foldToStreet2CBDone,
8096 foldToStreet3CBChance,
8097 foldToStreet3CBDone,
8098 foldToStreet4CBChance,
8099 foldToStreet4CBDone,
8100 common,
8101 committed,
8102 winnings,
8103 rake,
8104 rakeDealt,
8105 rakeContributed,
8106 rakeWeighted,
8107 totalProfit,
8108 allInEV,
8109 showdownWinnings,
8110 nonShowdownWinnings,
8111 street1CheckCallRaiseChance,
8112 street1CheckCallDone,
8113 street1CheckRaiseDone,
8114 street2CheckCallRaiseChance,
8115 street2CheckCallDone,
8116 street2CheckRaiseDone,
8117 street3CheckCallRaiseChance,
8118 street3CheckCallDone,
8119 street3CheckRaiseDone,
8120 street4CheckCallRaiseChance,
8121 street4CheckCallDone,
8122 street4CheckRaiseDone,
8123 street0Calls,
8124 street1Calls,
8125 street2Calls,
8126 street3Calls,
8127 street4Calls,
8128 street0Bets,
8129 street1Bets,
8130 street2Bets,
8131 street3Bets,
8132 street4Bets,
8133 street0Raises,
8134 street1Raises,
8135 street2Raises,
8136 street3Raises,
8137 street4Raises,
8138 street1Discards,
8139 street2Discards,
8140 street3Discards
8141 FROM SessionsCache
8142 WHERE endTime>=%s
8143 AND startTime<=%s
8144 AND gametypeId=%s
8145 AND playerId=%s"""
8147 self.query['select_TC'] = """
8148 SELECT id, startTime, endTime
8149 FROM TourneysCache TC
8150 WHERE tourneyId=%s
8151 AND playerId=%s"""
8153 ####################################
8154 # insert
8155 ####################################
8157 self.query['insert_W'] = """insert into Weeks (
8158 weekStart)
8159 values (%s)"""
8161 self.query['insert_M'] = """insert into Months (
8162 monthStart)
8163 values (%s)"""
8165 self.query['insert_S'] = """insert into Sessions (
8166 weekId,
8167 monthId,
8168 sessionStart,
8169 sessionEnd)
8170 values (%s, %s, %s, %s)"""
8172 self.query['insert_SC'] = """insert into SessionsCache (
8173 sessionId,
8174 startTime,
8175 endTime,
8176 gametypeId,
8177 playerId,
8178 n,
8179 street0VPIChance,
8180 street0VPI,
8181 street0AggrChance,
8182 street0Aggr,
8183 street0CalledRaiseChance,
8184 street0CalledRaiseDone,
8185 street0_2BChance,
8186 street0_2BDone,
8187 street0_3BChance,
8188 street0_3BDone,
8189 street0_4BChance,
8190 street0_4BDone,
8191 street0_C4BChance,
8192 street0_C4BDone,
8193 street0_FoldTo2BChance,
8194 street0_FoldTo2BDone,
8195 street0_FoldTo3BChance,
8196 street0_FoldTo3BDone,
8197 street0_FoldTo4BChance,
8198 street0_FoldTo4BDone,
8199 street0_SqueezeChance,
8200 street0_SqueezeDone,
8201 raiseToStealChance,
8202 raiseToStealDone,
8203 stealChance,
8204 stealDone,
8205 success_Steal,
8206 street1Seen,
8207 street2Seen,
8208 street3Seen,
8209 street4Seen,
8210 sawShowdown,
8211 street1Aggr,
8212 street2Aggr,
8213 street3Aggr,
8214 street4Aggr,
8215 otherRaisedStreet0,
8216 otherRaisedStreet1,
8217 otherRaisedStreet2,
8218 otherRaisedStreet3,
8219 otherRaisedStreet4,
8220 foldToOtherRaisedStreet0,
8221 foldToOtherRaisedStreet1,
8222 foldToOtherRaisedStreet2,
8223 foldToOtherRaisedStreet3,
8224 foldToOtherRaisedStreet4,
8225 wonWhenSeenStreet1,
8226 wonWhenSeenStreet2,
8227 wonWhenSeenStreet3,
8228 wonWhenSeenStreet4,
8229 wonAtSD,
8230 raiseFirstInChance,
8231 raisedFirstIn,
8232 foldBbToStealChance,
8233 foldedBbToSteal,
8234 foldSbToStealChance,
8235 foldedSbToSteal,
8236 street1CBChance,
8237 street1CBDone,
8238 street2CBChance,
8239 street2CBDone,
8240 street3CBChance,
8241 street3CBDone,
8242 street4CBChance,
8243 street4CBDone,
8244 foldToStreet1CBChance,
8245 foldToStreet1CBDone,
8246 foldToStreet2CBChance,
8247 foldToStreet2CBDone,
8248 foldToStreet3CBChance,
8249 foldToStreet3CBDone,
8250 foldToStreet4CBChance,
8251 foldToStreet4CBDone,
8252 common,
8253 committed,
8254 winnings,
8255 rake,
8256 rakeDealt,
8257 rakeContributed,
8258 rakeWeighted,
8259 totalProfit,
8260 allInEV,
8261 showdownWinnings,
8262 nonShowdownWinnings,
8263 street1CheckCallRaiseChance,
8264 street1CheckCallDone,
8265 street1CheckRaiseDone,
8266 street2CheckCallRaiseChance,
8267 street2CheckCallDone,
8268 street2CheckRaiseDone,
8269 street3CheckCallRaiseChance,
8270 street3CheckCallDone,
8271 street3CheckRaiseDone,
8272 street4CheckCallRaiseChance,
8273 street4CheckCallDone,
8274 street4CheckRaiseDone,
8275 street0Calls,
8276 street1Calls,
8277 street2Calls,
8278 street3Calls,
8279 street4Calls,
8280 street0Bets,
8281 street1Bets,
8282 street2Bets,
8283 street3Bets,
8284 street4Bets,
8285 street0Raises,
8286 street1Raises,
8287 street2Raises,
8288 street3Raises,
8289 street4Raises,
8290 street1Discards,
8291 street2Discards,
8292 street3Discards
8293 )
8294 values (%s, %s, %s, %s, %s,
8295 %s, %s, %s, %s, %s,
8296 %s, %s, %s, %s, %s,
8297 %s, %s, %s, %s, %s,
8298 %s, %s, %s, %s, %s,
8299 %s, %s, %s, %s, %s,
8300 %s, %s, %s, %s, %s,
8301 %s, %s, %s, %s, %s,
8302 %s, %s, %s, %s, %s,
8303 %s, %s, %s, %s, %s,
8304 %s, %s, %s, %s, %s,
8305 %s, %s, %s, %s, %s,
8306 %s, %s, %s, %s, %s,
8307 %s, %s, %s, %s, %s,
8308 %s, %s, %s, %s, %s,
8309 %s, %s, %s, %s, %s,
8310 %s, %s, %s, %s, %s,
8311 %s, %s, %s, %s, %s,
8312 %s, %s, %s, %s, %s,
8313 %s, %s, %s, %s, %s,
8314 %s, %s, %s, %s, %s,
8315 %s, %s, %s, %s, %s,
8316 %s, %s, %s, %s, %s,
8317 %s, %s, %s, %s, %s)"""
8319 self.query['insert_TC'] = """insert into TourneysCache (
8320 sessionId,
8321 startTime,
8322 endTime,
8323 tourneyId,
8324 playerId,
8325 n,
8326 street0VPIChance,
8327 street0VPI,
8328 street0AggrChance,
8329 street0Aggr,
8330 street0CalledRaiseChance,
8331 street0CalledRaiseDone,
8332 street0_2BChance,
8333 street0_2BDone,
8334 street0_3BChance,
8335 street0_3BDone,
8336 street0_4BChance,
8337 street0_4BDone,
8338 street0_C4BChance,
8339 street0_C4BDone,
8340 street0_FoldTo2BChance,
8341 street0_FoldTo2BDone,
8342 street0_FoldTo3BChance,
8343 street0_FoldTo3BDone,
8344 street0_FoldTo4BChance,
8345 street0_FoldTo4BDone,
8346 street0_SqueezeChance,
8347 street0_SqueezeDone,
8348 raiseToStealChance,
8349 raiseToStealDone,
8350 stealChance,
8351 stealDone,
8352 success_Steal,
8353 street1Seen,
8354 street2Seen,
8355 street3Seen,
8356 street4Seen,
8357 sawShowdown,
8358 street1Aggr,
8359 street2Aggr,
8360 street3Aggr,
8361 street4Aggr,
8362 otherRaisedStreet0,
8363 otherRaisedStreet1,
8364 otherRaisedStreet2,
8365 otherRaisedStreet3,
8366 otherRaisedStreet4,
8367 foldToOtherRaisedStreet0,
8368 foldToOtherRaisedStreet1,
8369 foldToOtherRaisedStreet2,
8370 foldToOtherRaisedStreet3,
8371 foldToOtherRaisedStreet4,
8372 wonWhenSeenStreet1,
8373 wonWhenSeenStreet2,
8374 wonWhenSeenStreet3,
8375 wonWhenSeenStreet4,
8376 wonAtSD,
8377 raiseFirstInChance,
8378 raisedFirstIn,
8379 foldBbToStealChance,
8380 foldedBbToSteal,
8381 foldSbToStealChance,
8382 foldedSbToSteal,
8383 street1CBChance,
8384 street1CBDone,
8385 street2CBChance,
8386 street2CBDone,
8387 street3CBChance,
8388 street3CBDone,
8389 street4CBChance,
8390 street4CBDone,
8391 foldToStreet1CBChance,
8392 foldToStreet1CBDone,
8393 foldToStreet2CBChance,
8394 foldToStreet2CBDone,
8395 foldToStreet3CBChance,
8396 foldToStreet3CBDone,
8397 foldToStreet4CBChance,
8398 foldToStreet4CBDone,
8399 common,
8400 committed,
8401 winnings,
8402 rake,
8403 rakeDealt,
8404 rakeContributed,
8405 rakeWeighted,
8406 totalProfit,
8407 allInEV,
8408 showdownWinnings,
8409 nonShowdownWinnings,
8410 street1CheckCallRaiseChance,
8411 street1CheckCallDone,
8412 street1CheckRaiseDone,
8413 street2CheckCallRaiseChance,
8414 street2CheckCallDone,
8415 street2CheckRaiseDone,
8416 street3CheckCallRaiseChance,
8417 street3CheckCallDone,
8418 street3CheckRaiseDone,
8419 street4CheckCallRaiseChance,
8420 street4CheckCallDone,
8421 street4CheckRaiseDone,
8422 street0Calls,
8423 street1Calls,
8424 street2Calls,
8425 street3Calls,
8426 street4Calls,
8427 street0Bets,
8428 street1Bets,
8429 street2Bets,
8430 street3Bets,
8431 street4Bets,
8432 street0Raises,
8433 street1Raises,
8434 street2Raises,
8435 street3Raises,
8436 street4Raises,
8437 street1Discards,
8438 street2Discards,
8439 street3Discards
8440 )
8441 values (%s, %s, %s, %s, %s,
8442 %s, %s, %s, %s, %s,
8443 %s, %s, %s, %s, %s,
8444 %s, %s, %s, %s, %s,
8445 %s, %s, %s, %s, %s,
8446 %s, %s, %s, %s, %s,
8447 %s, %s, %s, %s, %s,
8448 %s, %s, %s, %s, %s,
8449 %s, %s, %s, %s, %s,
8450 %s, %s, %s, %s, %s,
8451 %s, %s, %s, %s, %s,
8452 %s, %s, %s, %s, %s,
8453 %s, %s, %s, %s, %s,
8454 %s, %s, %s, %s, %s,
8455 %s, %s, %s, %s, %s,
8456 %s, %s, %s, %s, %s,
8457 %s, %s, %s, %s, %s,
8458 %s, %s, %s, %s, %s,
8459 %s, %s, %s, %s, %s,
8460 %s, %s, %s, %s, %s,
8461 %s, %s, %s, %s, %s,
8462 %s, %s, %s, %s, %s,
8463 %s, %s, %s, %s, %s,
8464 %s, %s, %s, %s, %s)"""
8466 ####################################
8467 # update
8468 ####################################
8470 self.query['update_WM_S'] = """
8471 UPDATE Sessions SET
8472 weekId=%s,
8473 monthId=%s
8474 WHERE id=%s"""
8476 self.query['update_S'] = """
8477 UPDATE Sessions SET
8478 weekId=%s,
8479 monthId=%s,
8480 sessionStart=%s,
8481 sessionEnd=%s
8482 WHERE id=%s"""
8484 self.query['update_SC'] = """
8485 UPDATE SessionsCache SET
8486 startTime=%s,
8487 endTime=%s,
8488 n=n+%s,
8489 street0VPIChance=street0VPIChance+%s,
8490 street0VPI=street0VPI+%s,
8491 street0AggrChance=street0AggrChance+%s,
8492 street0Aggr=street0Aggr+%s,
8493 street0CalledRaiseChance=street0CalledRaiseChance+%s,
8494 street0CalledRaiseDone=street0CalledRaiseDone+%s,
8495 street0_2BChance=street0_2BChance+%s,
8496 street0_2BDone=street0_2BDone+%s,
8497 street0_3BChance=street0_3BChance+%s,
8498 street0_3BDone=street0_3BDone+%s,
8499 street0_4BChance=street0_4BChance+%s,
8500 street0_4BDone=street0_4BDone+%s,
8501 street0_C4BChance=street0_C4BChance+%s,
8502 street0_C4BDone=street0_C4BDone+%s,
8503 street0_FoldTo2BChance=street0_FoldTo2BChance+%s,
8504 street0_FoldTo2BDone=street0_FoldTo2BDone+%s,
8505 street0_FoldTo3BChance=street0_FoldTo3BChance+%s,
8506 street0_FoldTo3BDone=street0_FoldTo3BDone+%s,
8507 street0_FoldTo4BChance=street0_FoldTo4BChance+%s,
8508 street0_FoldTo4BDone=street0_FoldTo4BDone+%s,
8509 street0_SqueezeChance=street0_SqueezeChance+%s,
8510 street0_SqueezeDone=street0_SqueezeDone+%s,
8511 raiseToStealChance=raiseToStealChance+%s,
8512 raiseToStealDone=raiseToStealDone+%s,
8513 stealChance=stealChance+%s,
8514 stealDone=stealDone+%s,
8515 success_Steal=success_Steal+%s,
8516 street1Seen=street1Seen+%s,
8517 street2Seen=street2Seen+%s,
8518 street3Seen=street3Seen+%s,
8519 street4Seen=street4Seen+%s,
8520 sawShowdown=sawShowdown+%s,
8521 street1Aggr=street1Aggr+%s,
8522 street2Aggr=street2Aggr+%s,
8523 street3Aggr=street3Aggr+%s,
8524 street4Aggr=street4Aggr+%s,
8525 otherRaisedStreet0=otherRaisedStreet0+%s,
8526 otherRaisedStreet1=otherRaisedStreet1+%s,
8527 otherRaisedStreet2=otherRaisedStreet2+%s,
8528 otherRaisedStreet3=otherRaisedStreet3+%s,
8529 otherRaisedStreet4=otherRaisedStreet4+%s,
8530 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s,
8531 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s,
8532 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s,
8533 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s,
8534 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s,
8535 wonWhenSeenStreet1=wonWhenSeenStreet1+%s,
8536 wonWhenSeenStreet2=wonWhenSeenStreet2+%s,
8537 wonWhenSeenStreet3=wonWhenSeenStreet3+%s,
8538 wonWhenSeenStreet4=wonWhenSeenStreet4+%s,
8539 wonAtSD=wonAtSD+%s,
8540 raiseFirstInChance=raiseFirstInChance+%s,
8541 raisedFirstIn=raisedFirstIn+%s,
8542 foldBbToStealChance=foldBbToStealChance+%s,
8543 foldedBbToSteal=foldedBbToSteal+%s,
8544 foldSbToStealChance=foldSbToStealChance+%s,
8545 foldedSbToSteal=foldedSbToSteal+%s,
8546 street1CBChance=street1CBChance+%s,
8547 street1CBDone=street1CBDone+%s,
8548 street2CBChance=street2CBChance+%s,
8549 street2CBDone=street2CBDone+%s,
8550 street3CBChance=street3CBChance+%s,
8551 street3CBDone=street3CBDone+%s,
8552 street4CBChance=street4CBChance+%s,
8553 street4CBDone=street4CBDone+%s,
8554 foldToStreet1CBChance=foldToStreet1CBChance+%s,
8555 foldToStreet1CBDone=foldToStreet1CBDone+%s,
8556 foldToStreet2CBChance=foldToStreet2CBChance+%s,
8557 foldToStreet2CBDone=foldToStreet2CBDone+%s,
8558 foldToStreet3CBChance=foldToStreet3CBChance+%s,
8559 foldToStreet3CBDone=foldToStreet3CBDone+%s,
8560 foldToStreet4CBChance=foldToStreet4CBChance+%s,
8561 foldToStreet4CBDone=foldToStreet4CBDone+%s,
8562 common=common+%s,
8563 committed=committed+%s,
8564 winnings=winnings+%s,
8565 rake=rake+%s,
8566 rakeDealt=rakeDealt+%s,
8567 rakeContributed=rakeContributed+%s,
8568 rakeWeighted=rakeWeighted+%s,
8569 totalProfit=totalProfit+%s,
8570 allInEV=allInEV+%s,
8571 showdownWinnings=showdownWinnings+%s,
8572 nonShowdownWinnings=nonShowdownWinnings+%s,
8573 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s,
8574 street1CheckCallDone=street1CheckCallDone+%s,
8575 street1CheckRaiseDone=street1CheckRaiseDone+%s,
8576 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s,
8577 street2CheckCallDone=street2CheckCallDone+%s,
8578 street2CheckRaiseDone=street2CheckRaiseDone+%s,
8579 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s,
8580 street3CheckCallDone=street3CheckCallDone+%s,
8581 street3CheckRaiseDone=street3CheckRaiseDone+%s,
8582 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s,
8583 street4CheckCallDone=street4CheckCallDone+%s,
8584 street4CheckRaiseDone=street4CheckRaiseDone+%s,
8585 street0Calls=street0Calls+%s,
8586 street1Calls=street1Calls+%s,
8587 street2Calls=street2Calls+%s,
8588 street3Calls=street3Calls+%s,
8589 street4Calls=street4Calls+%s,
8590 street0Bets=street0Bets+%s,
8591 street1Bets=street1Bets+%s,
8592 street2Bets=street2Bets+%s,
8593 street3Bets=street3Bets+%s,
8594 street4Bets=street4Bets+%s,
8595 street0Raises=street0Raises+%s,
8596 street1Raises=street1Raises+%s,
8597 street2Raises=street2Raises+%s,
8598 street3Raises=street3Raises+%s,
8599 street4Raises=street4Raises+%s,
8600 street1Discards=street1Discards+%s,
8601 street2Discards=street2Discards+%s,
8602 street3Discards=street3Discards+%s
8603 WHERE id=%s"""
8605 self.query['update_TC'] = """
8606 UPDATE TourneysCache SET
8607 <UPDATE>
8608 n=n+%s,
8609 street0VPIChance=street0VPIChance+%s,
8610 street0VPI=street0VPI+%s,
8611 street0AggrChance=street0AggrChance+%s,
8612 street0Aggr=street0Aggr+%s,
8613 street0CalledRaiseChance=street0CalledRaiseChance+%s,
8614 street0CalledRaiseDone=street0CalledRaiseDone+%s,
8615 street0_2BChance=street0_2BChance+%s,
8616 street0_2BDone=street0_2BDone+%s,
8617 street0_3BChance=street0_3BChance+%s,
8618 street0_3BDone=street0_3BDone+%s,
8619 street0_4BChance=street0_4BChance+%s,
8620 street0_4BDone=street0_4BDone+%s,
8621 street0_C4BChance=street0_C4BChance+%s,
8622 street0_C4BDone=street0_C4BDone+%s,
8623 street0_FoldTo2BChance=street0_FoldTo2BChance+%s,
8624 street0_FoldTo2BDone=street0_FoldTo2BDone+%s,
8625 street0_FoldTo3BChance=street0_FoldTo3BChance+%s,
8626 street0_FoldTo3BDone=street0_FoldTo3BDone+%s,
8627 street0_FoldTo4BChance=street0_FoldTo4BChance+%s,
8628 street0_FoldTo4BDone=street0_FoldTo4BDone+%s,
8629 street0_SqueezeChance=street0_SqueezeChance+%s,
8630 street0_SqueezeDone=street0_SqueezeDone+%s,
8631 raiseToStealChance=raiseToStealChance+%s,
8632 raiseToStealDone=raiseToStealDone+%s,
8633 stealChance=stealChance+%s,
8634 stealDone=stealDone+%s,
8635 success_Steal=success_Steal+%s,
8636 street1Seen=street1Seen+%s,
8637 street2Seen=street2Seen+%s,
8638 street3Seen=street3Seen+%s,
8639 street4Seen=street4Seen+%s,
8640 sawShowdown=sawShowdown+%s,
8641 street1Aggr=street1Aggr+%s,
8642 street2Aggr=street2Aggr+%s,
8643 street3Aggr=street3Aggr+%s,
8644 street4Aggr=street4Aggr+%s,
8645 otherRaisedStreet0=otherRaisedStreet0+%s,
8646 otherRaisedStreet1=otherRaisedStreet1+%s,
8647 otherRaisedStreet2=otherRaisedStreet2+%s,
8648 otherRaisedStreet3=otherRaisedStreet3+%s,
8649 otherRaisedStreet4=otherRaisedStreet4+%s,
8650 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s,
8651 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s,
8652 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s,
8653 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s,
8654 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s,
8655 wonWhenSeenStreet1=wonWhenSeenStreet1+%s,
8656 wonWhenSeenStreet2=wonWhenSeenStreet2+%s,
8657 wonWhenSeenStreet3=wonWhenSeenStreet3+%s,
8658 wonWhenSeenStreet4=wonWhenSeenStreet4+%s,
8659 wonAtSD=wonAtSD+%s,
8660 raiseFirstInChance=raiseFirstInChance+%s,
8661 raisedFirstIn=raisedFirstIn+%s,
8662 foldBbToStealChance=foldBbToStealChance+%s,
8663 foldedBbToSteal=foldedBbToSteal+%s,
8664 foldSbToStealChance=foldSbToStealChance+%s,
8665 foldedSbToSteal=foldedSbToSteal+%s,
8666 street1CBChance=street1CBChance+%s,
8667 street1CBDone=street1CBDone+%s,
8668 street2CBChance=street2CBChance+%s,
8669 street2CBDone=street2CBDone+%s,
8670 street3CBChance=street3CBChance+%s,
8671 street3CBDone=street3CBDone+%s,
8672 street4CBChance=street4CBChance+%s,
8673 street4CBDone=street4CBDone+%s,
8674 foldToStreet1CBChance=foldToStreet1CBChance+%s,
8675 foldToStreet1CBDone=foldToStreet1CBDone+%s,
8676 foldToStreet2CBChance=foldToStreet2CBChance+%s,
8677 foldToStreet2CBDone=foldToStreet2CBDone+%s,
8678 foldToStreet3CBChance=foldToStreet3CBChance+%s,
8679 foldToStreet3CBDone=foldToStreet3CBDone+%s,
8680 foldToStreet4CBChance=foldToStreet4CBChance+%s,
8681 foldToStreet4CBDone=foldToStreet4CBDone+%s,
8682 common=common+%s,
8683 committed=committed+%s,
8684 winnings=winnings+%s,
8685 rake=rake+%s,
8686 rakeDealt=rakeDealt+%s,
8687 rakeContributed=rakeContributed+%s,
8688 rakeWeighted=rakeWeighted+%s,
8689 totalProfit=totalProfit+%s,
8690 allInEV=allInEV+%s,
8691 showdownWinnings=showdownWinnings+%s,
8692 nonShowdownWinnings=nonShowdownWinnings+%s,
8693 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s,
8694 street1CheckCallDone=street1CheckCallDone+%s,
8695 street1CheckRaiseDone=street1CheckRaiseDone+%s,
8696 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s,
8697 street2CheckCallDone=street2CheckCallDone+%s,
8698 street2CheckRaiseDone=street2CheckRaiseDone+%s,
8699 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s,
8700 street3CheckCallDone=street3CheckCallDone+%s,
8701 street3CheckRaiseDone=street3CheckRaiseDone+%s,
8702 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s,
8703 street4CheckCallDone=street4CheckCallDone+%s,
8704 street4CheckRaiseDone=street4CheckRaiseDone+%s,
8705 street0Calls=street0Calls+%s,
8706 street1Calls=street1Calls+%s,
8707 street2Calls=street2Calls+%s,
8708 street3Calls=street3Calls+%s,
8709 street4Calls=street4Calls+%s,
8710 street0Bets=street0Bets+%s,
8711 street1Bets=street1Bets+%s,
8712 street2Bets=street2Bets+%s,
8713 street3Bets=street3Bets+%s,
8714 street4Bets=street4Bets+%s,
8715 street0Raises=street0Raises+%s,
8716 street1Raises=street1Raises+%s,
8717 street2Raises=street2Raises+%s,
8718 street3Raises=street3Raises+%s,
8719 street4Raises=street4Raises+%s,
8720 street1Discards=street1Discards+%s,
8721 street2Discards=street2Discards+%s,
8722 street3Discards=street3Discards+%s
8723 WHERE tourneyId=%s
8724 AND playerId=%s"""
8726 ####################################
8727 # delete
8728 ####################################
8730 self.query['delete_S'] = """
8731 DELETE FROM Sessions
8732 WHERE id=%s"""
8734 self.query['delete_SC'] = """
8735 DELETE FROM SessionsCache
8736 WHERE id=%s"""
8738 ####################################
8739 # update SessionsCache, Hands, Tourneys
8740 ####################################
8742 self.query['update_S_SC'] = """
8743 UPDATE SessionsCache SET
8744 sessionId=%s
8745 WHERE sessionId=%s"""
8747 self.query['update_S_TC'] = """
8748 UPDATE TourneysCache SET
8749 sessionId=%s
8750 WHERE sessionId=%s"""
8752 self.query['update_S_T'] = """
8753 UPDATE Tourneys SET
8754 sessionId=%s
8755 WHERE sessionId=%s"""
8757 self.query['update_S_H'] = """
8758 UPDATE Hands SET
8759 sessionId=%s
8760 WHERE sessionId=%s"""
8762 ####################################
8763 # update Tourneys w. sessionIds, hands, start/end
8764 ####################################
8766 self.query['updateTourneysSessions'] = """
8767 UPDATE Tourneys SET
8768 sessionId=%s
8769 WHERE id=%s"""
8771 ####################################
8772 # Database management queries
8773 ####################################
8775 if db_server == 'mysql':
8776 self.query['analyze'] = """
8777 analyze table Actions, Autorates, Backings, Boards, Files, Gametypes, Hands, HandsActions, HandsPlayers,
8778 HandsStove, HudCache, Players, RawHands, RawTourneys, Sessions, Settings, Sites,
8779 Tourneys, TourneysPlayers, TourneyTypes
8780 """
8781 elif db_server == 'postgresql':
8782 self.query['analyze'] = "analyze"
8783 elif db_server == 'sqlite':
8784 self.query['analyze'] = "analyze"
8787 if db_server == 'mysql':
8788 self.query['vacuum'] = """
8789 optimize table Actions, Autorates, Backings, Boards, Files, Gametypes, Hands, HandsActions, HandsPlayers,
8790 HandsStove, HudCache, Players, RawHands, RawTourneys, Sessions, Settings, Sites,
8791 Tourneys, TourneysPlayers, TourneyTypes
8792 """
8793 elif db_server == 'postgresql':
8794 self.query['vacuum'] = """ vacuum """
8795 elif db_server == 'sqlite':
8796 self.query['vacuum'] = """ vacuum """
8798 if db_server == 'mysql':
8799 self.query['switchLockOn'] = """
8800 UPDATE InsertLock k1,
8801 (SELECT count(locked) as locks FROM InsertLock WHERE locked=True) as k2 SET
8802 k1.locked=%s
8803 WHERE k1.id=%s
8804 AND k2.locks = 0"""
8806 if db_server == 'mysql':
8807 self.query['switchLockOff'] = """
8808 UPDATE InsertLock SET
8809 locked=%s
8810 WHERE id=%s"""
8812 if db_server == 'mysql':
8813 self.query['lockForInsert'] = """
8814 lock tables Hands write, HandsPlayers write, HandsActions write, Players write
8815 , HudCache write, Gametypes write, Sites write, Tourneys write
8816 , TourneysPlayers write, TourneyTypes write, Autorates write
8817 """
8818 elif db_server == 'postgresql':
8819 self.query['lockForInsert'] = ""
8820 elif db_server == 'sqlite':
8821 self.query['lockForInsert'] = ""
8823 self.query['getGametypeFL'] = """SELECT id
8824 FROM Gametypes
8825 WHERE siteId=%s
8826 AND type=%s
8827 AND category=%s
8828 AND limitType=%s
8829 AND smallBet=%s
8830 AND bigBet=%s
8831 AND maxSeats=%s
8832 AND ante=%s
8833 """ #TODO: seems odd to have limitType variable in this query
8835 self.query['getGametypeNL'] = """SELECT id
8836 FROM Gametypes
8837 WHERE siteId=%s
8838 AND type=%s
8839 AND category=%s
8840 AND limitType=%s
8841 AND currency=%s
8842 AND mix=%s
8843 AND smallBlind=%s
8844 AND bigBlind=%s
8845 AND maxSeats=%s
8846 AND ante=%s
8847 AND buyinType=%s
8848 AND fast=%s
8849 AND newToGame=%s
8850 AND homeGame=%s
8851 AND split=%s
8852 """ #TODO: seems odd to have limitType variable in this query
8854 self.query['insertGameTypes'] = """insert into Gametypes (siteId, currency, type, base, category, limitType, hiLo, mix,
8855 smallBlind, bigBlind, smallBet, bigBet, maxSeats, ante, buyinType, fast, newToGame, homeGame, split)
8856 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
8858 self.query['isAlreadyInDB'] = """SELECT H.id FROM Hands H
8859 INNER JOIN Gametypes G ON (H.gametypeId = G.id)
8860 WHERE siteHandNo=%s AND G.siteId=%s<heroSeat>
8861 """
8863 self.query['getTourneyTypeIdByTourneyNo'] = """SELECT tt.id,
8864 tt.siteId,
8865 tt.currency,
8866 tt.buyin,
8867 tt.fee,
8868 tt.category,
8869 tt.limitType,
8870 tt.maxSeats,
8871 tt.sng,
8872 tt.knockout,
8873 tt.koBounty,
8874 tt.progressive,
8875 tt.rebuy,
8876 tt.rebuyCost,
8877 tt.addOn,
8878 tt.addOnCost,
8879 tt.speed,
8880 tt.shootout,
8881 tt.matrix,
8882 tt.fast,
8883 tt.stack,
8884 tt.step,
8885 tt.stepNo,
8886 tt.chance,
8887 tt.chanceCount,
8888 tt.multiEntry,
8889 tt.reEntry,
8890 tt.homeGame,
8891 tt.newToGame,
8892 tt.split,
8893 tt.fifty50,
8894 tt.time,
8895 tt.timeAmt,
8896 tt.satellite,
8897 tt.doubleOrNothing,
8898 tt.cashOut,
8899 tt.onDemand,
8900 tt.flighted,
8901 tt.guarantee,
8902 tt.guaranteeAmt
8903 FROM TourneyTypes tt
8904 INNER JOIN Tourneys t ON (t.tourneyTypeId = tt.id)
8905 WHERE t.siteTourneyNo=%s AND tt.siteId=%s
8906 """
8908 self.query['getTourneyTypeId'] = """SELECT id
8909 FROM TourneyTypes
8910 WHERE siteId=%s
8911 AND currency=%s
8912 AND buyin=%s
8913 AND fee=%s
8914 AND category=%s
8915 AND limitType=%s
8916 AND maxSeats=%s
8917 AND sng=%s
8918 AND knockout=%s
8919 AND koBounty=%s
8920 AND progressive=%s
8921 AND rebuy=%s
8922 AND rebuyCost=%s
8923 AND addOn=%s
8924 AND addOnCost=%s
8925 AND speed=%s
8926 AND shootout=%s
8927 AND matrix=%s
8928 AND fast=%s
8929 AND stack=%s
8930 AND step=%s
8931 AND stepNo=%s
8932 AND chance=%s
8933 AND chanceCount=%s
8934 AND multiEntry=%s
8935 AND reEntry=%s
8936 AND homeGame=%s
8937 AND newToGame=%s
8938 AND split=%s
8939 AND fifty50=%s
8940 AND time=%s
8941 AND timeAmt=%s
8942 AND satellite=%s
8943 AND doubleOrNothing=%s
8944 AND cashOut=%s
8945 AND onDemand=%s
8946 AND flighted=%s
8947 AND guarantee=%s
8948 AND guaranteeAmt=%s
8949 """
8951 self.query['insertTourneyType'] = """insert into TourneyTypes (
8952 siteId, currency, buyin, fee, category, limitType, maxSeats, sng, knockout, koBounty, progressive,
8953 rebuy, rebuyCost, addOn, addOnCost, speed, shootout, matrix, fast,
8954 stack, step, stepNo, chance, chanceCount, multiEntry, reEntry, homeGame, newToGame, split,
8955 fifty50, time, timeAmt, satellite, doubleOrNothing, cashOut, onDemand, flighted, guarantee, guaranteeAmt
8956 )
8957 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
8958 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
8959 """
8961 if db_server == 'sqlite':
8962 self.query['updateTourneyTypeId'] = """UPDATE Tourneys
8963 SET tourneyTypeId = %s
8964 WHERE tourneyTypeId in (SELECT id FROM TourneyTypes WHERE siteId=%s)
8965 AND siteTourneyNo=%s
8966 """
8967 elif db_server == 'postgresql':
8968 self.query['updateTourneyTypeId'] = """UPDATE Tourneys t
8969 SET tourneyTypeId = %s
8970 FROM TourneyTypes tt
8971 WHERE t.tourneyTypeId = tt.id
8972 AND tt.siteId=%s
8973 AND t.siteTourneyNo=%s
8974 """
8975 else:
8976 self.query['updateTourneyTypeId'] = """UPDATE Tourneys t INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
8977 SET tourneyTypeId = %s
8978 WHERE tt.siteId=%s AND t.siteTourneyNo=%s
8979 """
8981 self.query['selectTourneyWithTypeId'] = """SELECT id
8982 FROM Tourneys
8983 WHERE tourneyTypeId = %s
8984 """
8986 self.query['deleteTourneyTypeId'] = """DELETE FROM TourneyTypes WHERE id = %s
8987 """
8989 self.query['getTourneyByTourneyNo'] = """SELECT t.*
8990 FROM Tourneys t
8991 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
8992 WHERE tt.siteId=%s AND t.siteTourneyNo=%s
8993 """
8995 self.query['getTourneyInfo'] = """SELECT tt.*, t.*
8996 FROM Tourneys t
8997 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
8998 INNER JOIN Sites s ON (tt.siteId = s.id)
8999 WHERE s.name=%s AND t.siteTourneyNo=%s
9000 """
9002 self.query['getSiteTourneyNos'] = """SELECT t.siteTourneyNo
9003 FROM Tourneys t
9004 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
9005 INNER JOIN Sites s ON (tt.siteId = s.id)
9006 WHERE tt.siteId=%s
9007 """
9009 self.query['getTourneyPlayerInfo'] = """SELECT tp.*
9010 FROM Tourneys t
9011 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
9012 INNER JOIN Sites s ON (tt.siteId = s.id)
9013 INNER JOIN TourneysPlayers tp ON (tp.tourneyId = t.id)
9014 INNER JOIN Players p ON (p.id = tp.playerId)
9015 WHERE s.name=%s AND t.siteTourneyNo=%s AND p.name=%s
9016 """
9018 self.query['insertTourney'] = """insert into Tourneys (
9019 tourneyTypeId, sessionId, siteTourneyNo, entries, prizepool,
9020 startTime, endTime, tourneyName, totalRebuyCount, totalAddOnCount,
9021 comment, commentTs, added, addedCurrency)
9022 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
9023 """
9025 self.query['updateTourney'] = """UPDATE Tourneys
9026 SET entries = %s,
9027 prizepool = %s,
9028 startTime = %s,
9029 endTime = %s,
9030 tourneyName = %s,
9031 totalRebuyCount = %s,
9032 totalAddOnCount = %s,
9033 comment = %s,
9034 commentTs = %s,
9035 added = %s,
9036 addedCurrency = %s
9037 WHERE id=%s
9038 """
9040 self.query['updateTourneyStart'] = """UPDATE Tourneys
9041 SET startTime = %s
9042 WHERE id=%s
9043 """
9045 self.query['updateTourneyEnd'] = """UPDATE Tourneys
9046 SET endTime = %s
9047 WHERE id=%s
9048 """
9050 self.query['getTourneysPlayersByIds'] = """SELECT *
9051 FROM TourneysPlayers
9052 WHERE tourneyId=%s AND playerId=%s AND entryId=%s
9053 """
9055 self.query['getTourneysPlayersByTourney'] = """SELECT playerId, entryId
9056 FROM TourneysPlayers
9057 WHERE tourneyId=%s
9058 """
9060 self.query['updateTourneysPlayer'] = """UPDATE TourneysPlayers
9061 SET rank = %s,
9062 winnings = %s,
9063 winningsCurrency = %s,
9064 rebuyCount = %s,
9065 addOnCount = %s,
9066 koCount = %s
9067 WHERE id=%s
9068 """
9070 self.query['updateTourneysPlayerBounties'] = """UPDATE TourneysPlayers
9071 SET koCount = case when koCount is null then %s else koCount+%s end
9072 WHERE id=%s
9073 """
9075 self.query['insertTourneysPlayer'] = """insert into TourneysPlayers (
9076 tourneyId,
9077 playerId,
9078 entryId,
9079 rank,
9080 winnings,
9081 winningsCurrency,
9082 rebuyCount,
9083 addOnCount,
9084 koCount
9085 )
9086 values (%s, %s, %s, %s, %s,
9087 %s, %s, %s, %s)
9088 """
9090 self.query['selectHandsPlayersWithWrongTTypeId'] = """SELECT id
9091 FROM HandsPlayers
9092 WHERE tourneyTypeId <> %s AND (TourneysPlayersId+0=%s)
9093 """
9095# self.query['updateHandsPlayersForTTypeId2'] = """UPDATE HandsPlayers
9096# SET tourneyTypeId= %s
9097# WHERE (TourneysPlayersId+0=%s)
9098# """
9100 self.query['updateHandsPlayersForTTypeId'] = """UPDATE HandsPlayers
9101 SET tourneyTypeId= %s
9102 WHERE (id=%s)
9103 """
9106 self.query['handsPlayersTTypeId_joiner'] = " OR TourneysPlayersId+0="
9107 self.query['handsPlayersTTypeId_joiner_id'] = " OR id="
9109 self.query['store_hand'] = """insert into Hands (
9110 tablename,
9111 sitehandno,
9112 tourneyId,
9113 gametypeid,
9114 sessionId,
9115 fileId,
9116 startTime,
9117 importtime,
9118 seats,
9119 heroSeat,
9120 maxPosition,
9121 texture,
9122 playersVpi,
9123 boardcard1,
9124 boardcard2,
9125 boardcard3,
9126 boardcard4,
9127 boardcard5,
9128 runItTwice,
9129 playersAtStreet1,
9130 playersAtStreet2,
9131 playersAtStreet3,
9132 playersAtStreet4,
9133 playersAtShowdown,
9134 street0Raises,
9135 street1Raises,
9136 street2Raises,
9137 street3Raises,
9138 street4Raises,
9139 street0Pot,
9140 street1Pot,
9141 street2Pot,
9142 street3Pot,
9143 street4Pot,
9144 finalPot
9145 )
9146 values
9147 (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
9148 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
9149 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
9150 %s, %s)"""
9153 self.query['store_hands_players'] = """insert into HandsPlayers (
9154 handId,
9155 playerId,
9156 startCash,
9157 effStack,
9158 startBounty,
9159 endBounty,
9160 seatNo,
9161 sitout,
9162 card1,
9163 card2,
9164 card3,
9165 card4,
9166 card5,
9167 card6,
9168 card7,
9169 card8,
9170 card9,
9171 card10,
9172 card11,
9173 card12,
9174 card13,
9175 card14,
9176 card15,
9177 card16,
9178 card17,
9179 card18,
9180 card19,
9181 card20,
9182 common,
9183 committed,
9184 winnings,
9185 rake,
9186 rakeDealt,
9187 rakeContributed,
9188 rakeWeighted,
9189 totalProfit,
9190 allInEV,
9191 street0VPIChance,
9192 street0VPI,
9193 street1Seen,
9194 street2Seen,
9195 street3Seen,
9196 street4Seen,
9197 sawShowdown,
9198 showed,
9199 street0AllIn,
9200 street1AllIn,
9201 street2AllIn,
9202 street3AllIn,
9203 street4AllIn,
9204 wentAllIn,
9205 street0AggrChance,
9206 street0Aggr,
9207 street1Aggr,
9208 street2Aggr,
9209 street3Aggr,
9210 street4Aggr,
9211 street1CBChance,
9212 street2CBChance,
9213 street3CBChance,
9214 street4CBChance,
9215 street1CBDone,
9216 street2CBDone,
9217 street3CBDone,
9218 street4CBDone,
9219 wonWhenSeenStreet1,
9220 wonWhenSeenStreet2,
9221 wonWhenSeenStreet3,
9222 wonWhenSeenStreet4,
9223 wonAtSD,
9224 position,
9225 street0InPosition,
9226 street1InPosition,
9227 street2InPosition,
9228 street3InPosition,
9229 street4InPosition,
9230 street0FirstToAct,
9231 street1FirstToAct,
9232 street2FirstToAct,
9233 street3FirstToAct,
9234 street4FirstToAct,
9235 tourneysPlayersId,
9236 startCards,
9237 street0CalledRaiseChance,
9238 street0CalledRaiseDone,
9239 street0_2BChance,
9240 street0_2BDone,
9241 street0_3BChance,
9242 street0_3BDone,
9243 street0_4BChance,
9244 street0_4BDone,
9245 street0_C4BChance,
9246 street0_C4BDone,
9247 street0_FoldTo2BChance,
9248 street0_FoldTo2BDone,
9249 street0_FoldTo3BChance,
9250 street0_FoldTo3BDone,
9251 street0_FoldTo4BChance,
9252 street0_FoldTo4BDone,
9253 street0_SqueezeChance,
9254 street0_SqueezeDone,
9255 raiseToStealChance,
9256 raiseToStealDone,
9257 stealChance,
9258 stealDone,
9259 success_Steal,
9260 otherRaisedStreet0,
9261 otherRaisedStreet1,
9262 otherRaisedStreet2,
9263 otherRaisedStreet3,
9264 otherRaisedStreet4,
9265 foldToOtherRaisedStreet0,
9266 foldToOtherRaisedStreet1,
9267 foldToOtherRaisedStreet2,
9268 foldToOtherRaisedStreet3,
9269 foldToOtherRaisedStreet4,
9270 raiseFirstInChance,
9271 raisedFirstIn,
9272 foldBbToStealChance,
9273 foldedBbToSteal,
9274 foldSbToStealChance,
9275 foldedSbToSteal,
9276 foldToStreet1CBChance,
9277 foldToStreet1CBDone,
9278 foldToStreet2CBChance,
9279 foldToStreet2CBDone,
9280 foldToStreet3CBChance,
9281 foldToStreet3CBDone,
9282 foldToStreet4CBChance,
9283 foldToStreet4CBDone,
9284 street1CheckCallRaiseChance,
9285 street1CheckCallDone,
9286 street1CheckRaiseDone,
9287 street2CheckCallRaiseChance,
9288 street2CheckCallDone,
9289 street2CheckRaiseDone,
9290 street3CheckCallRaiseChance,
9291 street3CheckCallDone,
9292 street3CheckRaiseDone,
9293 street4CheckCallRaiseChance,
9294 street4CheckCallDone,
9295 street4CheckRaiseDone,
9296 street0Calls,
9297 street1Calls,
9298 street2Calls,
9299 street3Calls,
9300 street4Calls,
9301 street0Bets,
9302 street1Bets,
9303 street2Bets,
9304 street3Bets,
9305 street4Bets,
9306 street0Raises,
9307 street1Raises,
9308 street2Raises,
9309 street3Raises,
9310 street4Raises,
9311 street1Discards,
9312 street2Discards,
9313 street3Discards,
9314 handString
9315 )
9316 values (
9317 %s, %s, %s, %s, %s,
9318 %s, %s, %s, %s, %s,
9319 %s, %s, %s, %s, %s,
9320 %s, %s, %s, %s, %s,
9321 %s, %s, %s, %s, %s,
9322 %s, %s, %s, %s, %s,
9323 %s, %s, %s, %s, %s,
9324 %s, %s, %s, %s, %s,
9325 %s, %s, %s, %s, %s,
9326 %s, %s, %s, %s, %s,
9327 %s, %s, %s, %s, %s,
9328 %s, %s, %s, %s, %s,
9329 %s, %s, %s, %s, %s,
9330 %s, %s, %s, %s, %s,
9331 %s, %s, %s, %s, %s,
9332 %s, %s, %s, %s, %s,
9333 %s, %s, %s, %s, %s,
9334 %s, %s, %s, %s, %s,
9335 %s, %s, %s, %s, %s,
9336 %s, %s, %s, %s, %s,
9337 %s, %s, %s, %s, %s,
9338 %s, %s, %s, %s, %s,
9339 %s, %s, %s, %s, %s,
9340 %s, %s, %s, %s, %s,
9341 %s, %s, %s, %s, %s,
9342 %s, %s, %s, %s, %s,
9343 %s, %s, %s, %s, %s,
9344 %s, %s, %s, %s, %s,
9345 %s, %s, %s, %s, %s,
9346 %s, %s, %s, %s, %s,
9347 %s, %s, %s, %s, %s,
9348 %s, %s, %s, %s, %s,
9349 %s
9350 )"""
9352 self.query['store_hands_actions'] = """insert into HandsActions (
9353 handId,
9354 playerId,
9355 street,
9356 actionNo,
9357 streetActionNo,
9358 actionId,
9359 amount,
9360 raiseTo,
9361 amountCalled,
9362 numDiscarded,
9363 cardsDiscarded,
9364 allIn
9365 )
9366 values (
9367 %s, %s, %s, %s, %s,
9368 %s, %s, %s, %s, %s,
9369 %s, %s
9370 )"""
9372 self.query['store_hands_stove'] = """insert into HandsStove (
9373 handId,
9374 playerId,
9375 streetId,
9376 boardId,
9377 hiLo,
9378 rankId,
9379 value,
9380 cards,
9381 ev
9382 )
9383 values (
9384 %s, %s, %s, %s, %s,
9385 %s, %s, %s, %s
9386 )"""
9388 self.query['store_boards'] = """insert into Boards (
9389 handId,
9390 boardId,
9391 boardcard1,
9392 boardcard2,
9393 boardcard3,
9394 boardcard4,
9395 boardcard5
9396 )
9397 values (
9398 %s, %s, %s, %s, %s,
9399 %s, %s
9400 )"""
9402 self.query['store_hands_pots'] = """insert into HandsPots (
9403 handId,
9404 potId,
9405 boardId,
9406 hiLo,
9407 playerId,
9408 pot,
9409 collected,
9410 rake
9411 )
9412 values (
9413 %s, %s, %s, %s,
9414 %s, %s, %s, %s
9415 )"""
9417 ################################
9418 # queries for Files Table
9419 ################################
9421 self.query['get_id'] = """
9422 SELECT id
9423 FROM Files
9424 WHERE file=%s"""
9426 self.query['store_file'] = """ insert into Files (
9427 file,
9428 site,
9429 startTime,
9430 lastUpdate,
9431 hands,
9432 storedHands,
9433 dups,
9434 partial,
9435 skipped,
9436 errs,
9437 ttime100,
9438 finished)
9439 values (
9440 %s, %s, %s, %s, %s,
9441 %s, %s, %s, %s, %s,
9442 %s, %s
9443 )"""
9445 self.query['update_file'] = """
9446 UPDATE Files SET
9447 type=%s,
9448 lastUpdate=%s,
9449 endTime=%s,
9450 hands=hands+%s,
9451 storedHands=storedHands+%s,
9452 dups=dups+%s,
9453 partial=partial+%s,
9454 skipped=skipped+%s,
9455 errs=errs+%s,
9456 ttime100=ttime100+%s,
9457 finished=%s
9458 WHERE id=%s"""
9460 ################################
9461 # Counts for DB stats window
9462 ################################
9463 self.query['getHandCount'] = "SELECT COUNT(*) FROM Hands"
9464 self.query['getTourneyCount'] = "SELECT COUNT(*) FROM Tourneys"
9465 self.query['getTourneyTypeCount'] = "SELECT COUNT(*) FROM TourneyTypes"
9467 ################################
9468 # queries for dumpDatabase
9469 ################################
9470 for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
9471 self.query['get' + table] = u"SELECT * FROM " + table
9473 ################################
9474 # placeholders and substitution stuff
9475 ################################
9476 if db_server == 'mysql':
9477 self.query['placeholder'] = u'%s'
9478 elif db_server == 'postgresql':
9479 self.query['placeholder'] = u'%s'
9480 elif db_server == 'sqlite':
9481 self.query['placeholder'] = u'?'
9484 # If using sqlite, use the ? placeholder instead of %s
9485 if db_server == 'sqlite':
9486 for k, q in list(self.query.items()):
9487 self.query[k] = re.sub('%s', '?', q)
9489if __name__ == "__main__":
9490# just print the default queries and exit
9491 s = Sql()
9492 for key in s.query:
9493 print("For query " + key + ", sql =")
9494 print(s.query[key])