Coverage for SQL.py: 76%

547 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-18 00:10 +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 

21 

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 ?. 

26 

27######################################################################## 

28 

29# Standard Library modules 

30 

31import re 

32 

33# pyGTK modules 

34 

35# FreePokerTools modules 

36 

37 

38class 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 # 

44 

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"] = ( 

52 """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'""" 

53 ) 

54 elif db_server == "sqlite": 

55 self.query["list_tables"] = """SELECT name FROM sqlite_master 

56 WHERE type='table' 

57 ORDER BY name;""" 

58 

59 ################################ 

60 # List indexes 

61 ################################ 

62 if db_server == "mysql": 

63 self.query["list_indexes"] = """SHOW INDEXES""" 

64 elif db_server == "postgresql": 

65 self.query["list_indexes"] = """SELECT tablename, indexname FROM PG_INDEXES""" 

66 elif db_server == "sqlite": 

67 self.query["list_indexes"] = """SELECT name FROM sqlite_master 

68 WHERE type='index' 

69 ORDER BY name;""" 

70 

71 ################################################################## 

72 # Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax 

73 ################################################################## 

74 

75 self.query["drop_table"] = """DROP TABLE IF EXISTS """ 

76 

77 ################################################################## 

78 # Set transaction isolation level 

79 ################################################################## 

80 

81 if db_server == "mysql" or db_server == "postgresql": 

82 self.query["set tx level"] = """SET SESSION TRANSACTION 

83 ISOLATION LEVEL READ COMMITTED""" 

84 elif db_server == "sqlite": 

85 self.query["set tx level"] = """ """ 

86 

87 ################################ 

88 # Select basic info 

89 ################################ 

90 

91 self.query["getSiteId"] = """SELECT id from Sites where name = %s""" 

92 

93 self.query["getGames"] = """SELECT DISTINCT category from Gametypes""" 

94 

95 self.query["getCurrencies"] = """SELECT DISTINCT currency from Gametypes ORDER BY currency""" 

96 

97 self.query["getLimits"] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC""" 

98 

99 self.query["getTourneyTypesIds"] = "SELECT id FROM TourneyTypes" 

100 

101 self.query["getTourneyTypes"] = "SELECT DISTINCT tourneyName FROM Tourneys" 

102 

103 self.query["getTourneyNames"] = "SELECT tourneyName FROM Tourneys" 

104 

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

114 

115 elif db_server == "sqlite": 

116 self.query["createSettingsTable"] = """CREATE TABLE Settings 

117 (version INTEGER NOT NULL) """ 

118 

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

127 

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

150 

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

173 

174 ################################ 

175 # Create Actions 

176 ################################ 

177 

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

194 

195 ################################ 

196 # Create Rank 

197 ################################ 

198 

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

204 

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

213 

214 ################################ 

215 # Create StartCards 

216 ################################ 

217 

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

226 

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

234 

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

242 

243 ################################ 

244 # Create Sites 

245 ################################ 

246 

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

263 

264 ################################ 

265 # Create Backings 

266 ################################ 

267 

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

289 

290 ################################ 

291 # Create Gametypes 

292 ################################ 

293 

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

362 

363 ################################ 

364 # Create Players 

365 ################################ 

366 

367 if db_server == "mysql": 

368 self.query["createPlayersTable"] = """CREATE TABLE Players ( 

369 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

370 name VARCHAR(32) NOT NULL, 

371 siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), 

372 hero BOOLEAN,  

373 chars char(3), 

374 comment text, 

375 commentTs DATETIME, 

376 profil text, 

377 color_code VARCHAR(7) DEFAULT '#FFFFFF', 

378 symbol VARCHAR(10) DEFAULT '★'  

379 ) 

380 ENGINE=INNODB""" 

381 elif db_server == "postgresql": 

382 self.query["createPlayersTable"] = """CREATE TABLE Players ( 

383 id SERIAL, PRIMARY KEY (id), 

384 name VARCHAR(32), 

385 siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id), 

386 hero BOOLEAN, 

387 chars char(3), 

388 comment text, 

389 commentTs timestamp without time zone, 

390 profil text, 

391 color_code VARCHAR(7) DEFAULT '#FFFFFF', 

392 symbol VARCHAR(10) DEFAULT '★' )""" 

393 elif db_server == "sqlite": 

394 self.query["createPlayersTable"] = """CREATE TABLE Players ( 

395 id INTEGER PRIMARY KEY, 

396 name TEXT, 

397 siteId INTEGER, 

398 hero BOOLEAN, 

399 chars TEXT, 

400 comment TEXT, 

401 commentTs timestamp, 

402 profil TEXT, 

403 color_code TEXT DEFAULT '#FFFFFF', 

404 symbol TEXT DEFAULT '★',  

405 FOREIGN KEY(siteId) REFERENCES Sites(id) ON DELETE CASCADE)""" 

406 

407 ################################ 

408 # Create Autorates 

409 ################################ 

410 

411 if db_server == "mysql": 

412 self.query["createAutoratesTable"] = """CREATE TABLE Autorates ( 

413 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

414 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

415 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

416 description varchar(50) NOT NULL, 

417 shortDesc char(8) NOT NULL, 

418 ratingTime DATETIME NOT NULL, 

419 handCount int NOT NULL) 

420 ENGINE=INNODB""" 

421 elif db_server == "postgresql": 

422 self.query["createAutoratesTable"] = """CREATE TABLE Autorates ( 

423 id BIGSERIAL, PRIMARY KEY (id), 

424 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

425 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

426 description varchar(50), 

427 shortDesc char(8), 

428 ratingTime timestamp without time zone, 

429 handCount int)""" 

430 elif db_server == "sqlite": 

431 self.query["createAutoratesTable"] = """CREATE TABLE Autorates ( 

432 id INTEGER PRIMARY KEY, 

433 playerId INT, 

434 gametypeId INT, 

435 description TEXT, 

436 shortDesc TEXT, 

437 ratingTime timestamp, 

438 handCount int)""" 

439 

440 ################################ 

441 # Create Hands 

442 ################################ 

443 

444 if db_server == "mysql": 

445 self.query["createHandsTable"] = """CREATE TABLE Hands ( 

446 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

447 tableName VARCHAR(50) NOT NULL, 

448 siteHandNo BIGINT NOT NULL, 

449 tourneyId INT UNSIGNED, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

450 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

451 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

452 fileId INT(10) UNSIGNED NOT NULL, FOREIGN KEY (fileId) REFERENCES Files(id),  

453 startTime DATETIME NOT NULL, 

454 importTime DATETIME NOT NULL, 

455 seats TINYINT NOT NULL, 

456 heroSeat TINYINT NOT NULL, 

457 maxPosition TINYINT NOT NULL, 

458 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

459 boardcard2 smallint, 

460 boardcard3 smallint, 

461 boardcard4 smallint, 

462 boardcard5 smallint, 

463 texture smallint, 

464 runItTwice BOOLEAN, 

465 playersVpi SMALLINT NOT NULL, /* num of players vpi */ 

466 playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */ 

467 playersAtStreet2 SMALLINT NOT NULL, 

468 playersAtStreet3 SMALLINT NOT NULL, 

469 playersAtStreet4 SMALLINT NOT NULL, 

470 playersAtShowdown SMALLINT NOT NULL, 

471 street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */ 

472 street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */ 

473 street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */ 

474 street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */ 

475 street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */ 

476 street0Pot BIGINT, /* pot size at pre-flop/street2 */ 

477 street1Pot BIGINT, /* pot size at flop/street4 */ 

478 street2Pot BIGINT, /* pot size at turn/street5 */ 

479 street3Pot BIGINT, /* pot size at river/street6 */ 

480 street4Pot BIGINT, /* pot size at sd/street7 */ 

481 finalPot BIGINT, /* final pot size */ 

482 comment TEXT, 

483 commentTs DATETIME) 

484 ENGINE=INNODB""" 

485 elif db_server == "postgresql": 

486 self.query["createHandsTable"] = """CREATE TABLE Hands ( 

487 id BIGSERIAL, PRIMARY KEY (id), 

488 tableName VARCHAR(50) NOT NULL, 

489 siteHandNo BIGINT NOT NULL, 

490 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

491 gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

492 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

493 fileId BIGINT NOT NULL, FOREIGN KEY (fileId) REFERENCES Files(id), 

494 startTime timestamp without time zone NOT NULL, 

495 importTime timestamp without time zone NOT NULL, 

496 seats SMALLINT NOT NULL, 

497 heroSeat SMALLINT NOT NULL, 

498 maxPosition SMALLINT NOT NULL, 

499 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

500 boardcard2 smallint, 

501 boardcard3 smallint, 

502 boardcard4 smallint, 

503 boardcard5 smallint, 

504 texture smallint, 

505 runItTwice BOOLEAN, 

506 playersVpi SMALLINT NOT NULL, /* num of players vpi */ 

507 playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */ 

508 playersAtStreet2 SMALLINT NOT NULL, 

509 playersAtStreet3 SMALLINT NOT NULL, 

510 playersAtStreet4 SMALLINT NOT NULL, 

511 playersAtShowdown SMALLINT NOT NULL, 

512 street0Raises SMALLINT NOT NULL, /* num small bets paid to see flop/street4, including blind */ 

513 street1Raises SMALLINT NOT NULL, /* num small bets paid to see turn/street5 */ 

514 street2Raises SMALLINT NOT NULL, /* num big bets paid to see river/street6 */ 

515 street3Raises SMALLINT NOT NULL, /* num big bets paid to see sd/street7 */ 

516 street4Raises SMALLINT NOT NULL, /* num big bets paid to see showdown */ 

517 street0Pot BIGINT, /* pot size at preflop/street3 */ 

518 street1Pot BIGINT, /* pot size at flop/street4 */ 

519 street2Pot BIGINT, /* pot size at turn/street5 */ 

520 street3Pot BIGINT, /* pot size at river/street6 */ 

521 street4Pot BIGINT, /* pot size at sd/street7 */ 

522 finalPot BIGINT, /* final pot size */ 

523 comment TEXT, 

524 commentTs timestamp without time zone)""" 

525 elif db_server == "sqlite": 

526 self.query["createHandsTable"] = """CREATE TABLE Hands ( 

527 id INTEGER PRIMARY KEY, 

528 tableName TEXT(50) NOT NULL, 

529 siteHandNo INT NOT NULL, 

530 tourneyId INT, 

531 gametypeId INT NOT NULL, 

532 sessionId INT, 

533 fileId INT NOT NULL, 

534 startTime timestamp NOT NULL, 

535 importTime timestamp NOT NULL, 

536 seats INT NOT NULL, 

537 heroSeat INT NOT NULL, 

538 maxPosition INT NOT NULL, 

539 boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

540 boardcard2 INT, 

541 boardcard3 INT, 

542 boardcard4 INT, 

543 boardcard5 INT, 

544 texture INT, 

545 runItTwice BOOLEAN, 

546 playersVpi INT NOT NULL, /* num of players vpi */ 

547 playersAtStreet1 INT NOT NULL, /* num of players seeing flop/street4 */ 

548 playersAtStreet2 INT NOT NULL, 

549 playersAtStreet3 INT NOT NULL, 

550 playersAtStreet4 INT NOT NULL, 

551 playersAtShowdown INT NOT NULL, 

552 street0Raises INT NOT NULL, /* num small bets paid to see flop/street4, including blind */ 

553 street1Raises INT NOT NULL, /* num small bets paid to see turn/street5 */ 

554 street2Raises INT NOT NULL, /* num big bets paid to see river/street6 */ 

555 street3Raises INT NOT NULL, /* num big bets paid to see sd/street7 */ 

556 street4Raises INT NOT NULL, /* num big bets paid to see showdown */ 

557 street0Pot INT, /* pot size at preflop/street3 */ 

558 street1Pot INT, /* pot size at flop/street4 */ 

559 street2Pot INT, /* pot size at turn/street5 */ 

560 street3Pot INT, /* pot size at river/street6 */ 

561 street4Pot INT, /* pot size at sd/street7 */ 

562 finalPot INT, /* final pot size */ 

563 comment TEXT, 

564 commentTs timestamp)""" 

565 

566 ################################ 

567 # Create Boards 

568 ################################ 

569 

570 if db_server == "mysql": 

571 self.query["createBoardsTable"] = """CREATE TABLE Boards ( 

572 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

573 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

574 boardId smallint, 

575 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

576 boardcard2 smallint, 

577 boardcard3 smallint, 

578 boardcard4 smallint, 

579 boardcard5 smallint) 

580 ENGINE=INNODB""" 

581 elif db_server == "postgresql": 

582 self.query["createBoardsTable"] = """CREATE TABLE Boards ( 

583 id BIGSERIAL, PRIMARY KEY (id), 

584 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

585 boardId smallint, 

586 boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

587 boardcard2 smallint, 

588 boardcard3 smallint, 

589 boardcard4 smallint, 

590 boardcard5 smallint)""" 

591 elif db_server == "sqlite": 

592 self.query["createBoardsTable"] = """CREATE TABLE Boards ( 

593 id INTEGER PRIMARY KEY, 

594 handId INT NOT NULL, 

595 boardId INT, 

596 boardcard1 INT, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

597 boardcard2 INT, 

598 boardcard3 INT, 

599 boardcard4 INT, 

600 boardcard5 INT)""" 

601 

602 ################################ 

603 # Create TourneyTypes 

604 ################################ 

605 

606 if db_server == "mysql": 

607 self.query["createTourneyTypesTable"] = """CREATE TABLE TourneyTypes ( 

608 id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

609 siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), 

610 currency varchar(4), 

611 buyIn BIGINT, 

612 fee BIGINT, 

613 category varchar(9) NOT NULL, 

614 limitType char(2) NOT NULL, 

615 buyInChips BIGINT, 

616 stack varchar(8), 

617 maxSeats INT, 

618 rebuy BOOLEAN, 

619 rebuyCost BIGINT, 

620 rebuyFee BIGINT, 

621 rebuyChips BIGINT, 

622 addOn BOOLEAN, 

623 addOnCost BIGINT, 

624 addOnFee BIGINT, 

625 addOnChips BIGINT, 

626 knockout BOOLEAN, 

627 koBounty BIGINT, 

628 progressive BOOLEAN, 

629 step BOOLEAN, 

630 stepNo INT, 

631 chance BOOLEAN, 

632 chanceCount INT, 

633 speed varchar(10), 

634 shootout BOOLEAN, 

635 matrix BOOLEAN, 

636 multiEntry BOOLEAN, 

637 reEntry BOOLEAN, 

638 fast BOOLEAN,  

639 newToGame BOOLEAN, 

640 homeGame BOOLEAN, 

641 split BOOLEAN, 

642 sng BOOLEAN, 

643 fifty50 BOOLEAN, 

644 time BOOLEAN, 

645 timeAmt INT, 

646 satellite BOOLEAN, 

647 doubleOrNothing BOOLEAN, 

648 cashOut BOOLEAN, 

649 onDemand BOOLEAN, 

650 flighted BOOLEAN, 

651 guarantee BOOLEAN, 

652 guaranteeAmt BIGINT) 

653 ENGINE=INNODB""" 

654 elif db_server == "postgresql": 

655 self.query["createTourneyTypesTable"] = """CREATE TABLE TourneyTypes ( 

656 id SERIAL, PRIMARY KEY (id), 

657 siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id), 

658 currency varchar(4), 

659 buyin BIGINT, 

660 fee BIGINT, 

661 category varchar(9), 

662 limitType char(2), 

663 buyInChips BIGINT, 

664 stack varchar(8), 

665 maxSeats INT, 

666 rebuy BOOLEAN, 

667 rebuyCost BIGINT, 

668 rebuyFee BIGINT, 

669 rebuyChips BIGINT, 

670 addOn BOOLEAN, 

671 addOnCost BIGINT, 

672 addOnFee BIGINT, 

673 addOnChips BIGINT, 

674 knockout BOOLEAN, 

675 koBounty BIGINT, 

676 progressive BOOLEAN, 

677 step BOOLEAN, 

678 stepNo INT, 

679 chance BOOLEAN, 

680 chanceCount INT, 

681 speed varchar(10), 

682 shootout BOOLEAN, 

683 matrix BOOLEAN, 

684 multiEntry BOOLEAN, 

685 reEntry BOOLEAN, 

686 fast BOOLEAN, 

687 newToGame BOOLEAN, 

688 homeGame BOOLEAN, 

689 split BOOLEAN, 

690 sng BOOLEAN, 

691 fifty50 BOOLEAN, 

692 time BOOLEAN, 

693 timeAmt INT, 

694 satellite BOOLEAN, 

695 doubleOrNothing BOOLEAN, 

696 cashOut BOOLEAN, 

697 onDemand BOOLEAN, 

698 flighted BOOLEAN, 

699 guarantee BOOLEAN, 

700 guaranteeAmt BIGINT)""" 

701 elif db_server == "sqlite": 

702 self.query["createTourneyTypesTable"] = """CREATE TABLE TourneyTypes ( 

703 id INTEGER PRIMARY KEY, 

704 siteId INT NOT NULL, 

705 currency VARCHAR(4), 

706 buyin INT, 

707 fee INT, 

708 category TEXT, 

709 limitType TEXT, 

710 buyInChips INT, 

711 stack VARCHAR(8), 

712 maxSeats INT, 

713 rebuy BOOLEAN, 

714 rebuyCost INT, 

715 rebuyFee INT, 

716 rebuyChips INT, 

717 addOn BOOLEAN, 

718 addOnCost INT, 

719 addOnFee INT, 

720 addOnChips INT, 

721 knockout BOOLEAN, 

722 koBounty INT, 

723 progressive BOOLEAN, 

724 step BOOLEAN, 

725 stepNo INT, 

726 chance BOOLEAN, 

727 chanceCount INT, 

728 speed TEXT, 

729 shootout BOOLEAN, 

730 matrix BOOLEAN, 

731 multiEntry BOOLEAN, 

732 reEntry BOOLEAN, 

733 fast BOOLEAN, 

734 newToGame BOOLEAN, 

735 homeGame BOOLEAN, 

736 split BOOLEAN, 

737 sng BOOLEAN, 

738 fifty50 BOOLEAN, 

739 time BOOLEAN, 

740 timeAmt INT, 

741 satellite BOOLEAN, 

742 doubleOrNothing BOOLEAN, 

743 cashOut BOOLEAN, 

744 onDemand BOOLEAN, 

745 flighted BOOLEAN, 

746 guarantee BOOLEAN, 

747 guaranteeAmt INT)""" 

748 

749 ################################ 

750 # Create Tourneys 

751 ################################ 

752 

753 if db_server == "mysql": 

754 self.query["createTourneysTable"] = """CREATE TABLE Tourneys ( 

755 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

756 tourneyTypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

757 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

758 siteTourneyNo BIGINT NOT NULL, 

759 entries INT, 

760 prizepool BIGINT, 

761 startTime DATETIME, 

762 endTime DATETIME, 

763 tourneyName TEXT, 

764 totalRebuyCount INT, 

765 totalAddOnCount INT, 

766 added BIGINT, 

767 addedCurrency VARCHAR(4), 

768 comment TEXT, 

769 commentTs DATETIME) 

770 ENGINE=INNODB""" 

771 elif db_server == "postgresql": 

772 self.query["createTourneysTable"] = """CREATE TABLE Tourneys ( 

773 id SERIAL, PRIMARY KEY (id), 

774 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

775 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

776 siteTourneyNo BIGINT, 

777 entries INT, 

778 prizepool BIGINT, 

779 startTime timestamp without time zone, 

780 endTime timestamp without time zone, 

781 tourneyName TEXT, 

782 totalRebuyCount INT, 

783 totalAddOnCount INT, 

784 added BIGINT, 

785 addedCurrency VARCHAR(4), 

786 comment TEXT, 

787 commentTs timestamp without time zone)""" 

788 elif db_server == "sqlite": 

789 self.query["createTourneysTable"] = """CREATE TABLE Tourneys ( 

790 id INTEGER PRIMARY KEY, 

791 tourneyTypeId INT, 

792 sessionId INT, 

793 siteTourneyNo INT, 

794 entries INT, 

795 prizepool INT, 

796 startTime timestamp, 

797 endTime timestamp, 

798 tourneyName TEXT, 

799 totalRebuyCount INT, 

800 totalAddOnCount INT, 

801 added INT, 

802 addedCurrency VARCHAR(4), 

803 comment TEXT, 

804 commentTs timestamp)""" 

805 

806 ################################ 

807 # Create HandsPlayers 

808 ################################ 

809 

810 if db_server == "mysql": 

811 self.query["createHandsPlayersTable"] = """CREATE TABLE HandsPlayers ( 

812 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

813 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

814 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

815 startCash BIGINT NOT NULL, 

816 effStack BIGINT NOT NULL, 

817 startBounty BIGINT, 

818 endBounty BIGINT, 

819 position CHAR(1), 

820 seatNo SMALLINT NOT NULL, 

821 sitout BOOLEAN NOT NULL, 

822  

823 card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

824 card2 smallint NOT NULL, 

825 card3 smallint, 

826 card4 smallint, 

827 card5 smallint, 

828 card6 smallint, 

829 card7 smallint, 

830 card8 smallint, /* cards 8-20 for draw hands */ 

831 card9 smallint, 

832 card10 smallint, 

833 card11 smallint, 

834 card12 smallint, 

835 card13 smallint, 

836 card14 smallint, 

837 card15 smallint, 

838 card16 smallint, 

839 card17 smallint, 

840 card18 smallint, 

841 card19 smallint, 

842 card20 smallint, 

843 startCards SMALLINT UNSIGNED, FOREIGN KEY (startCards) REFERENCES StartCards(id), 

844  

845 common BIGINT NOT NULL, 

846 committed BIGINT NOT NULL,  

847 winnings BIGINT NOT NULL, 

848 rake BIGINT NOT NULL, 

849 rakeDealt NUMERIC NOT NULL, 

850 rakeContributed NUMERIC NOT NULL, 

851 rakeWeighted NUMERIC NOT NULL, 

852 totalProfit BIGINT, 

853 allInEV NUMERIC, 

854 comment text, 

855 commentTs DATETIME, 

856 tourneysPlayersId BIGINT UNSIGNED, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id), 

857 

858 wonWhenSeenStreet1 BOOLEAN, 

859 wonWhenSeenStreet2 BOOLEAN, 

860 wonWhenSeenStreet3 BOOLEAN, 

861 wonWhenSeenStreet4 BOOLEAN, 

862 wonAtSD BOOLEAN, 

863  

864 street0VPIChance BOOLEAN, 

865 street0VPI BOOLEAN, 

866 street0AggrChance BOOLEAN, 

867 street0Aggr BOOLEAN, 

868 street0CalledRaiseChance TINYINT, 

869 street0CalledRaiseDone TINYINT, 

870 street0_2BChance BOOLEAN, 

871 street0_2BDone BOOLEAN, 

872 street0_3BChance BOOLEAN, 

873 street0_3BDone BOOLEAN, 

874 street0_4BChance BOOLEAN, 

875 street0_C4BChance BOOLEAN, 

876 street0_4BDone BOOLEAN, 

877 street0_C4BDone BOOLEAN, 

878 street0_FoldTo2BChance BOOLEAN, 

879 street0_FoldTo2BDone BOOLEAN, 

880 street0_FoldTo3BChance BOOLEAN, 

881 street0_FoldTo3BDone BOOLEAN, 

882 street0_FoldTo4BChance BOOLEAN, 

883 street0_FoldTo4BDone BOOLEAN, 

884 street0_SqueezeChance BOOLEAN, 

885 street0_SqueezeDone BOOLEAN, 

886 

887 raiseToStealChance BOOLEAN, 

888 raiseToStealDone BOOLEAN, 

889 stealChance BOOLEAN, 

890 stealDone BOOLEAN, 

891 success_Steal BOOLEAN, 

892 

893 street1Seen BOOLEAN, 

894 street2Seen BOOLEAN, 

895 street3Seen BOOLEAN, 

896 street4Seen BOOLEAN, 

897 sawShowdown BOOLEAN, 

898 showed BOOLEAN, 

899  

900 street0AllIn BOOLEAN, 

901 street1AllIn BOOLEAN, 

902 street2AllIn BOOLEAN, 

903 street3AllIn BOOLEAN, 

904 street4AllIn BOOLEAN, 

905 wentAllIn BOOLEAN, 

906  

907 street0InPosition BOOLEAN, 

908 street1InPosition BOOLEAN, 

909 street2InPosition BOOLEAN, 

910 street3InPosition BOOLEAN, 

911 street4InPosition BOOLEAN, 

912 street0FirstToAct BOOLEAN, 

913 street1FirstToAct BOOLEAN, 

914 street2FirstToAct BOOLEAN, 

915 street3FirstToAct BOOLEAN, 

916 street4FirstToAct BOOLEAN, 

917 

918 street1Aggr BOOLEAN, 

919 street2Aggr BOOLEAN, 

920 street3Aggr BOOLEAN, 

921 street4Aggr BOOLEAN, 

922 

923 otherRaisedStreet0 BOOLEAN, 

924 otherRaisedStreet1 BOOLEAN, 

925 otherRaisedStreet2 BOOLEAN, 

926 otherRaisedStreet3 BOOLEAN, 

927 otherRaisedStreet4 BOOLEAN, 

928 foldToOtherRaisedStreet0 BOOLEAN, 

929 foldToOtherRaisedStreet1 BOOLEAN, 

930 foldToOtherRaisedStreet2 BOOLEAN, 

931 foldToOtherRaisedStreet3 BOOLEAN, 

932 foldToOtherRaisedStreet4 BOOLEAN, 

933 

934 raiseFirstInChance BOOLEAN, 

935 raisedFirstIn BOOLEAN, 

936 foldBbToStealChance BOOLEAN, 

937 foldedBbToSteal BOOLEAN, 

938 foldSbToStealChance BOOLEAN, 

939 foldedSbToSteal BOOLEAN, 

940 

941 street1CBChance BOOLEAN, 

942 street1CBDone BOOLEAN, 

943 street2CBChance BOOLEAN, 

944 street2CBDone BOOLEAN, 

945 street3CBChance BOOLEAN, 

946 street3CBDone BOOLEAN, 

947 street4CBChance BOOLEAN, 

948 street4CBDone BOOLEAN, 

949 

950 foldToStreet1CBChance BOOLEAN, 

951 foldToStreet1CBDone BOOLEAN, 

952 foldToStreet2CBChance BOOLEAN, 

953 foldToStreet2CBDone BOOLEAN, 

954 foldToStreet3CBChance BOOLEAN, 

955 foldToStreet3CBDone BOOLEAN, 

956 foldToStreet4CBChance BOOLEAN, 

957 foldToStreet4CBDone BOOLEAN, 

958 

959 street1CheckCallRaiseChance BOOLEAN, 

960 street1CheckCallDone BOOLEAN, 

961 street1CheckRaiseDone BOOLEAN, 

962 street2CheckCallRaiseChance BOOLEAN, 

963 street2CheckCallDone BOOLEAN, 

964 street2CheckRaiseDone BOOLEAN, 

965 street3CheckCallRaiseChance BOOLEAN, 

966 street3CheckCallDone BOOLEAN, 

967 street3CheckRaiseDone BOOLEAN, 

968 street4CheckCallRaiseChance BOOLEAN, 

969 street4CheckCallDone BOOLEAN, 

970 street4CheckRaiseDone BOOLEAN, 

971 

972 street0Calls TINYINT, 

973 street1Calls TINYINT, 

974 street2Calls TINYINT, 

975 street3Calls TINYINT, 

976 street4Calls TINYINT, 

977 street0Bets TINYINT, 

978 street1Bets TINYINT, 

979 street2Bets TINYINT, 

980 street3Bets TINYINT, 

981 street4Bets TINYINT, 

982 street0Raises TINYINT, 

983 street1Raises TINYINT, 

984 street2Raises TINYINT, 

985 street3Raises TINYINT, 

986 street4Raises TINYINT, 

987 street1Discards TINYINT, 

988 street2Discards TINYINT, 

989 street3Discards TINYINT, 

990  

991 handString TEXT, 

992 actionString VARCHAR(15)) 

993 ENGINE=INNODB""" 

994 elif db_server == "postgresql": 

995 self.query["createHandsPlayersTable"] = """CREATE TABLE HandsPlayers ( 

996 id BIGSERIAL, PRIMARY KEY (id), 

997 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

998 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

999 startCash BIGINT NOT NULL, 

1000 effStack BIGINT NOT NULL, 

1001 startBounty BIGINT, 

1002 endBounty BIGINT, 

1003 position CHAR(1), 

1004 seatNo SMALLINT NOT NULL, 

1005 sitout BOOLEAN NOT NULL, 

1006 

1007 card1 smallint NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

1008 card2 smallint NOT NULL, 

1009 card3 smallint, 

1010 card4 smallint, 

1011 card5 smallint, 

1012 card6 smallint, 

1013 card7 smallint, 

1014 card8 smallint, /* cards 8-20 for draw hands */ 

1015 card9 smallint, 

1016 card10 smallint, 

1017 card11 smallint, 

1018 card12 smallint, 

1019 card13 smallint, 

1020 card14 smallint, 

1021 card15 smallint, 

1022 card16 smallint, 

1023 card17 smallint, 

1024 card18 smallint, 

1025 card19 smallint, 

1026 card20 smallint,  

1027 startCards smallint, FOREIGN KEY (startCards) REFERENCES StartCards(id), 

1028 

1029 common BIGINT NOT NULL, 

1030 committed BIGINT NOT NULL, 

1031 winnings BIGINT NOT NULL, 

1032 rake BIGINT NOT NULL, 

1033 rakeDealt NUMERIC NOT NULL, 

1034 rakeContributed NUMERIC NOT NULL, 

1035 rakeWeighted NUMERIC NOT NULL, 

1036 totalProfit BIGINT, 

1037 allInEV NUMERIC, 

1038 comment text, 

1039 commentTs timestamp without time zone, 

1040 tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id), 

1041 

1042 wonWhenSeenStreet1 BOOLEAN, 

1043 wonWhenSeenStreet2 BOOLEAN, 

1044 wonWhenSeenStreet3 BOOLEAN, 

1045 wonWhenSeenStreet4 BOOLEAN, 

1046 wonAtSD BOOLEAN, 

1047 

1048 street0VPIChance BOOLEAN, 

1049 street0VPI BOOLEAN, 

1050 street0AggrChance BOOLEAN, 

1051 street0Aggr BOOLEAN, 

1052 street0CalledRaiseChance SMALLINT, 

1053 street0CalledRaiseDone SMALLINT, 

1054 street0_2BChance BOOLEAN, 

1055 street0_2BDone BOOLEAN, 

1056 street0_3BChance BOOLEAN, 

1057 street0_3BDone BOOLEAN, 

1058 street0_4BChance BOOLEAN, 

1059 street0_4BDone BOOLEAN, 

1060 street0_C4BChance BOOLEAN, 

1061 street0_C4BDone BOOLEAN, 

1062 street0_FoldTo2BChance BOOLEAN, 

1063 street0_FoldTo2BDone BOOLEAN, 

1064 street0_FoldTo3BChance BOOLEAN, 

1065 street0_FoldTo3BDone BOOLEAN, 

1066 street0_FoldTo4BChance BOOLEAN, 

1067 street0_FoldTo4BDone BOOLEAN, 

1068 street0_SqueezeChance BOOLEAN, 

1069 street0_SqueezeDone BOOLEAN, 

1070 

1071 raiseToStealChance BOOLEAN, 

1072 raiseToStealDone BOOLEAN, 

1073 stealChance BOOLEAN, 

1074 stealDone BOOLEAN, 

1075 success_Steal BOOLEAN, 

1076 

1077 street1Seen BOOLEAN, 

1078 street2Seen BOOLEAN, 

1079 street3Seen BOOLEAN, 

1080 street4Seen BOOLEAN, 

1081 sawShowdown BOOLEAN, 

1082 showed BOOLEAN, 

1083  

1084 street0AllIn BOOLEAN, 

1085 street1AllIn BOOLEAN, 

1086 street2AllIn BOOLEAN, 

1087 street3AllIn BOOLEAN, 

1088 street4AllIn BOOLEAN, 

1089 wentAllIn BOOLEAN, 

1090  

1091 street0InPosition BOOLEAN, 

1092 street1InPosition BOOLEAN, 

1093 street2InPosition BOOLEAN, 

1094 street3InPosition BOOLEAN, 

1095 street4InPosition BOOLEAN, 

1096 street0FirstToAct BOOLEAN, 

1097 street1FirstToAct BOOLEAN, 

1098 street2FirstToAct BOOLEAN, 

1099 street3FirstToAct BOOLEAN, 

1100 street4FirstToAct BOOLEAN, 

1101 

1102 street1Aggr BOOLEAN, 

1103 street2Aggr BOOLEAN, 

1104 street3Aggr BOOLEAN, 

1105 street4Aggr BOOLEAN, 

1106 

1107 otherRaisedStreet0 BOOLEAN, 

1108 otherRaisedStreet1 BOOLEAN, 

1109 otherRaisedStreet2 BOOLEAN, 

1110 otherRaisedStreet3 BOOLEAN, 

1111 otherRaisedStreet4 BOOLEAN, 

1112 foldToOtherRaisedStreet0 BOOLEAN, 

1113 foldToOtherRaisedStreet1 BOOLEAN, 

1114 foldToOtherRaisedStreet2 BOOLEAN, 

1115 foldToOtherRaisedStreet3 BOOLEAN, 

1116 foldToOtherRaisedStreet4 BOOLEAN, 

1117 

1118 raiseFirstInChance BOOLEAN, 

1119 raisedFirstIn BOOLEAN, 

1120 foldBbToStealChance BOOLEAN, 

1121 foldedBbToSteal BOOLEAN, 

1122 foldSbToStealChance BOOLEAN, 

1123 foldedSbToSteal BOOLEAN, 

1124 

1125 street1CBChance BOOLEAN, 

1126 street1CBDone BOOLEAN, 

1127 street2CBChance BOOLEAN, 

1128 street2CBDone BOOLEAN, 

1129 street3CBChance BOOLEAN, 

1130 street3CBDone BOOLEAN, 

1131 street4CBChance BOOLEAN, 

1132 street4CBDone BOOLEAN, 

1133 

1134 foldToStreet1CBChance BOOLEAN, 

1135 foldToStreet1CBDone BOOLEAN, 

1136 foldToStreet2CBChance BOOLEAN, 

1137 foldToStreet2CBDone BOOLEAN, 

1138 foldToStreet3CBChance BOOLEAN, 

1139 foldToStreet3CBDone BOOLEAN, 

1140 foldToStreet4CBChance BOOLEAN, 

1141 foldToStreet4CBDone BOOLEAN, 

1142 

1143 street1CheckCallRaiseChance BOOLEAN, 

1144 street1CheckCallDone BOOLEAN, 

1145 street1CheckRaiseDone BOOLEAN, 

1146 street2CheckCallRaiseChance BOOLEAN, 

1147 street2CheckCallDone BOOLEAN, 

1148 street2CheckRaiseDone BOOLEAN, 

1149 street3CheckCallRaiseChance BOOLEAN, 

1150 street3CheckCallDone BOOLEAN, 

1151 street3CheckRaiseDone BOOLEAN, 

1152 street4CheckCallRaiseChance BOOLEAN, 

1153 street4CheckCallDone BOOLEAN, 

1154 street4CheckRaiseDone BOOLEAN, 

1155 

1156 street0Calls SMALLINT, 

1157 street1Calls SMALLINT, 

1158 street2Calls SMALLINT, 

1159 street3Calls SMALLINT, 

1160 street4Calls SMALLINT, 

1161 street0Bets SMALLINT, 

1162 street1Bets SMALLINT, 

1163 street2Bets SMALLINT, 

1164 street3Bets SMALLINT, 

1165 street4Bets SMALLINT, 

1166 street0Raises SMALLINT, 

1167 street1Raises SMALLINT, 

1168 street2Raises SMALLINT, 

1169 street3Raises SMALLINT, 

1170 street4Raises SMALLINT, 

1171 street1Discards SMALLINT, 

1172 street2Discards SMALLINT, 

1173 street3Discards SMALLINT, 

1174  

1175 handString TEXT, 

1176 actionString VARCHAR(15))""" 

1177 elif db_server == "sqlite": 

1178 self.query["createHandsPlayersTable"] = """CREATE TABLE HandsPlayers ( 

1179 id INTEGER PRIMARY KEY, 

1180 handId INT NOT NULL, 

1181 playerId INT NOT NULL, 

1182 startCash INT NOT NULL, 

1183 effStack INT NOT NULL, 

1184 startBounty INT, 

1185 endBounty INT, 

1186 position TEXT, 

1187 seatNo INT NOT NULL, 

1188 sitout BOOLEAN NOT NULL, 

1189  

1190 card1 INT NOT NULL, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ 

1191 card2 INT NOT NULL, 

1192 card3 INT, 

1193 card4 INT, 

1194 card5 INT, 

1195 card6 INT, 

1196 card7 INT, 

1197 card8 INT, /* cards 8-20 for draw hands */ 

1198 card9 INT, 

1199 card10 INT, 

1200 card11 INT, 

1201 card12 INT, 

1202 card13 INT, 

1203 card14 INT, 

1204 card15 INT, 

1205 card16 INT, 

1206 card17 INT, 

1207 card18 INT, 

1208 card19 INT, 

1209 card20 INT, 

1210 startCards INT, 

1211  

1212 common INT NOT NULL, 

1213 committed INT NOT NULL, 

1214 winnings INT NOT NULL, 

1215 rake INT NOT NULL, 

1216 rakeDealt decimal NOT NULL, 

1217 rakeContributed decimal NOT NULL, 

1218 rakeWeighted decimal NOT NULL, 

1219 totalProfit INT, 

1220 allInEV decimal, 

1221 comment TEXT, 

1222 commentTs timestamp, 

1223 tourneysPlayersId INT, 

1224 

1225 wonWhenSeenStreet1 INT, 

1226 wonWhenSeenStreet2 INT, 

1227 wonWhenSeenStreet3 INT, 

1228 wonWhenSeenStreet4 INT, 

1229 wonAtSD INT, 

1230  

1231 street0VPIChance INT, 

1232 street0VPI INT, 

1233 street0AggrChance INT, 

1234 street0Aggr INT, 

1235 street0CalledRaiseChance INT, 

1236 street0CalledRaiseDone INT, 

1237 street0_2BChance INT, 

1238 street0_2BDone INT, 

1239 street0_3BChance INT, 

1240 street0_3BDone INT, 

1241 street0_4BChance INT, 

1242 street0_4BDone INT, 

1243 street0_C4BChance INT, 

1244 street0_C4BDone INT, 

1245 street0_FoldTo2BChance INT, 

1246 street0_FoldTo2BDone INT, 

1247 street0_FoldTo3BChance INT, 

1248 street0_FoldTo3BDone INT, 

1249 street0_FoldTo4BChance INT, 

1250 street0_FoldTo4BDone INT, 

1251 street0_SqueezeChance INT, 

1252 street0_SqueezeDone INT, 

1253 

1254 raiseToStealChance INT, 

1255 raiseToStealDone INT, 

1256 stealChance INT, 

1257 stealDone INT, 

1258 success_Steal INT, 

1259 

1260 street1Seen INT, 

1261 street2Seen INT, 

1262 street3Seen INT, 

1263 street4Seen INT, 

1264 sawShowdown INT, 

1265 showed INT, 

1266  

1267 street0AllIn INT, 

1268 street1AllIn INT, 

1269 street2AllIn INT, 

1270 street3AllIn INT, 

1271 street4AllIn INT, 

1272 wentAllIn INT, 

1273  

1274 street0InPosition INT, 

1275 street1InPosition INT, 

1276 street2InPosition INT, 

1277 street3InPosition INT, 

1278 street4InPosition INT, 

1279 street0FirstToAct INT, 

1280 street1FirstToAct INT, 

1281 street2FirstToAct INT, 

1282 street3FirstToAct INT, 

1283 street4FirstToAct INT, 

1284 

1285 street1Aggr INT, 

1286 street2Aggr INT, 

1287 street3Aggr INT, 

1288 street4Aggr INT, 

1289 

1290 otherRaisedStreet0 INT, 

1291 otherRaisedStreet1 INT, 

1292 otherRaisedStreet2 INT, 

1293 otherRaisedStreet3 INT, 

1294 otherRaisedStreet4 INT, 

1295 foldToOtherRaisedStreet0 INT, 

1296 foldToOtherRaisedStreet1 INT, 

1297 foldToOtherRaisedStreet2 INT, 

1298 foldToOtherRaisedStreet3 INT, 

1299 foldToOtherRaisedStreet4 INT, 

1300 

1301 raiseFirstInChance INT, 

1302 raisedFirstIn INT, 

1303 foldBbToStealChance INT, 

1304 foldedBbToSteal INT, 

1305 foldSbToStealChance INT, 

1306 foldedSbToSteal INT, 

1307 

1308 street1CBChance INT, 

1309 street1CBDone INT, 

1310 street2CBChance INT, 

1311 street2CBDone INT, 

1312 street3CBChance INT, 

1313 street3CBDone INT, 

1314 street4CBChance INT, 

1315 street4CBDone INT, 

1316 

1317 foldToStreet1CBChance INT, 

1318 foldToStreet1CBDone INT, 

1319 foldToStreet2CBChance INT, 

1320 foldToStreet2CBDone INT, 

1321 foldToStreet3CBChance INT, 

1322 foldToStreet3CBDone INT, 

1323 foldToStreet4CBChance INT, 

1324 foldToStreet4CBDone INT, 

1325 

1326 street1CheckCallRaiseChance INT, 

1327 street1CheckCallDone INT, 

1328 street1CheckRaiseDone INT, 

1329 street2CheckCallRaiseChance INT, 

1330 street2CheckCallDone INT, 

1331 street2CheckRaiseDone INT, 

1332 street3CheckCallRaiseChance INT, 

1333 street3CheckCallDone INT, 

1334 street3CheckRaiseDone INT, 

1335 street4CheckCallRaiseChance INT, 

1336 street4CheckCallDone INT, 

1337 street4CheckRaiseDone INT, 

1338 

1339 street0Calls INT, 

1340 street1Calls INT, 

1341 street2Calls INT, 

1342 street3Calls INT, 

1343 street4Calls INT, 

1344 street0Bets INT, 

1345 street1Bets INT, 

1346 street2Bets INT, 

1347 street3Bets INT, 

1348 street4Bets INT, 

1349 street0Raises INT, 

1350 street1Raises INT, 

1351 street2Raises INT, 

1352 street3Raises INT, 

1353 street4Raises INT, 

1354 street1Discards INT, 

1355 street2Discards INT, 

1356 street3Discards INT, 

1357  

1358 handString TEXT, 

1359 actionString VARCHAR(15)) 

1360 """ 

1361 

1362 ################################ 

1363 # Create TourneysPlayers 

1364 ################################ 

1365 

1366 if db_server == "mysql": 

1367 self.query["createTourneysPlayersTable"] = """CREATE TABLE TourneysPlayers ( 

1368 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1369 tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

1370 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1371 entryId INT, 

1372 rank INT, 

1373 winnings BIGINT, 

1374 winningsCurrency VARCHAR(4), 

1375 rebuyCount INT, 

1376 addOnCount INT, 

1377 koCount NUMERIC, 

1378 comment TEXT, 

1379 commentTs DATETIME) 

1380 ENGINE=INNODB""" 

1381 elif db_server == "postgresql": 

1382 self.query["createTourneysPlayersTable"] = """CREATE TABLE TourneysPlayers ( 

1383 id BIGSERIAL, PRIMARY KEY (id), 

1384 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

1385 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

1386 entryId INT, 

1387 rank INT, 

1388 winnings BIGINT, 

1389 winningsCurrency VARCHAR(4), 

1390 rebuyCount INT, 

1391 addOnCount INT, 

1392 koCount NUMERIC, 

1393 comment TEXT, 

1394 commentTs timestamp without time zone)""" 

1395 elif db_server == "sqlite": 

1396 self.query["createTourneysPlayersTable"] = """CREATE TABLE TourneysPlayers ( 

1397 id INTEGER PRIMARY KEY, 

1398 tourneyId INT, 

1399 playerId INT, 

1400 entryId INT, 

1401 rank INT, 

1402 winnings INT, 

1403 winningsCurrency VARCHAR(4), 

1404 rebuyCount INT, 

1405 addOnCount INT, 

1406 koCount decimal, 

1407 comment TEXT, 

1408 commentTs timestamp, 

1409 FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

1410 FOREIGN KEY (playerId) REFERENCES Players(id) 

1411 )""" 

1412 

1413 ################################ 

1414 # Create HandsActions 

1415 ################################ 

1416 

1417 if db_server == "mysql": 

1418 self.query["createHandsActionsTable"] = """CREATE TABLE HandsActions ( 

1419 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1420 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1421 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1422 street SMALLINT NOT NULL, 

1423 actionNo SMALLINT NOT NULL, 

1424 streetActionNo SMALLINT NOT NULL, 

1425 actionId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (actionId) REFERENCES Actions(id), 

1426 amount BIGINT NOT NULL, 

1427 raiseTo BIGINT NOT NULL, 

1428 amountCalled BIGINT NOT NULL, 

1429 numDiscarded SMALLINT NOT NULL, 

1430 cardsDiscarded varchar(14), 

1431 allIn BOOLEAN NOT NULL) 

1432 ENGINE=INNODB""" 

1433 elif db_server == "postgresql": 

1434 self.query["createHandsActionsTable"] = """CREATE TABLE HandsActions ( 

1435 id BIGSERIAL, PRIMARY KEY (id), 

1436 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1437 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1438 street SMALLINT, 

1439 actionNo SMALLINT, 

1440 streetActionNo SMALLINT, 

1441 actionId SMALLINT, FOREIGN KEY (actionId) REFERENCES Actions(id), 

1442 amount BIGINT, 

1443 raiseTo BIGINT, 

1444 amountCalled BIGINT, 

1445 numDiscarded SMALLINT, 

1446 cardsDiscarded varchar(14), 

1447 allIn BOOLEAN)""" 

1448 elif db_server == "sqlite": 

1449 self.query["createHandsActionsTable"] = """CREATE TABLE HandsActions ( 

1450 id INTEGER PRIMARY KEY, 

1451 handId INT NOT NULL, 

1452 playerId INT NOT NULL, 

1453 street SMALLINT, 

1454 actionNo SMALLINT, 

1455 streetActionNo SMALLINT, 

1456 actionId SMALLINT, 

1457 amount INT, 

1458 raiseTo INT, 

1459 amountCalled INT, 

1460 numDiscarded SMALLINT, 

1461 cardsDiscarded TEXT, 

1462 allIn BOOLEAN 

1463 )""" 

1464 

1465 ################################ 

1466 # Create HandsStove 

1467 ################################ 

1468 

1469 if db_server == "mysql": 

1470 self.query["createHandsStoveTable"] = """CREATE TABLE HandsStove ( 

1471 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1472 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1473 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1474 streetId SMALLINT, 

1475 boardId SMALLINT, 

1476 hiLo char(1) NOT NULL, 

1477 rankId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (rankId) REFERENCES Rank(id), 

1478 value BIGINT, 

1479 cards VARCHAR(5), 

1480 ev NUMERIC) 

1481 ENGINE=INNODB""" 

1482 elif db_server == "postgresql": 

1483 self.query["createHandsStoveTable"] = """CREATE TABLE HandsStove ( 

1484 id BIGSERIAL, PRIMARY KEY (id), 

1485 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1486 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1487 streetId SMALLINT, 

1488 boardId SMALLINT, 

1489 hiLo char(1) NOT NULL, 

1490 rankId SMALLINT NOT NULL, FOREIGN KEY (rankId) REFERENCES Rank(id), 

1491 value BIGINT, 

1492 cards VARCHAR(5), 

1493 ev NUMERIC)""" 

1494 elif db_server == "sqlite": 

1495 self.query["createHandsStoveTable"] = """CREATE TABLE HandsStove ( 

1496 id INTEGER PRIMARY KEY, 

1497 handId INT NOT NULL, 

1498 playerId INT NOT NULL, 

1499 streetId INT, 

1500 boardId INT, 

1501 hiLo TEXT NOT NULL, 

1502 rankId INT, 

1503 value INT, 

1504 cards TEXT, 

1505 ev decimal 

1506 )""" 

1507 

1508 ################################ 

1509 # Create HandsPots 

1510 ################################ 

1511 

1512 if db_server == "mysql": 

1513 self.query["createHandsPotsTable"] = """CREATE TABLE HandsPots ( 

1514 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1515 handId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1516 potId SMALLINT, 

1517 boardId SMALLINT, 

1518 hiLo char(1) NOT NULL, 

1519 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1520 pot BIGINT, 

1521 collected BIGINT, 

1522 rake INT) 

1523 ENGINE=INNODB""" 

1524 elif db_server == "postgresql": 

1525 self.query["createHandsPotsTable"] = """CREATE TABLE HandsPots ( 

1526 id BIGSERIAL, PRIMARY KEY (id), 

1527 handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id), 

1528 potId SMALLINT, 

1529 boardId SMALLINT, 

1530 hiLo char(1) NOT NULL, 

1531 playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1532 pot BIGINT, 

1533 collected BIGINT, 

1534 rake INT)""" 

1535 elif db_server == "sqlite": 

1536 self.query["createHandsPotsTable"] = """CREATE TABLE HandsPots ( 

1537 id INTEGER PRIMARY KEY, 

1538 handId INT NOT NULL, 

1539 potId INT, 

1540 boardId INT, 

1541 hiLo TEXT NOT NULL, 

1542 playerId INT NOT NULL, 

1543 pot INT, 

1544 collected INT, 

1545 rake INT 

1546 )""" 

1547 

1548 ################################ 

1549 # Create Files 

1550 ################################ 

1551 

1552 if db_server == "mysql": 

1553 self.query["createFilesTable"] = """CREATE TABLE Files ( 

1554 id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1555 file text NOT NULL, 

1556 site VARCHAR(32), 

1557 type VARCHAR(7), 

1558 startTime DATETIME NOT NULL, 

1559 lastUpdate DATETIME NOT NULL, 

1560 endTime DATETIME, 

1561 hands INT, 

1562 storedHands INT, 

1563 dups INT, 

1564 partial INT, 

1565 skipped INT, 

1566 errs INT, 

1567 ttime100 INT, 

1568 finished BOOLEAN) 

1569 ENGINE=INNODB""" 

1570 elif db_server == "postgresql": 

1571 self.query["createFilesTable"] = """CREATE TABLE Files ( 

1572 id BIGSERIAL, PRIMARY KEY (id), 

1573 file TEXT NOT NULL, 

1574 site VARCHAR(32), 

1575 type VARCHAR(7), 

1576 startTime timestamp without time zone NOT NULL, 

1577 lastUpdate timestamp without time zone NOT NULL, 

1578 endTime timestamp without time zone, 

1579 hands INT, 

1580 storedHands INT, 

1581 dups INT, 

1582 partial INT, 

1583 skipped INT, 

1584 errs INT, 

1585 ttime100 INT, 

1586 finished BOOLEAN)""" 

1587 elif db_server == "sqlite": 

1588 self.query["createFilesTable"] = """CREATE TABLE Files ( 

1589 id INTEGER PRIMARY KEY, 

1590 file TEXT NOT NULL, 

1591 site VARCHAR(32), 

1592 type VARCHAR(7), 

1593 startTime timestamp NOT NULL, 

1594 lastUpdate timestamp NOT NULL, 

1595 endTime timestamp, 

1596 hands INT, 

1597 storedHands INT, 

1598 dups INT, 

1599 partial INT, 

1600 skipped INT, 

1601 errs INT, 

1602 ttime100 INT, 

1603 finished BOOLEAN 

1604 )""" 

1605 

1606 ################################ 

1607 # Create HudCache 

1608 ################################ 

1609 

1610 if db_server == "mysql": 

1611 self.query["createHudCacheTable"] = """CREATE TABLE HudCache ( 

1612 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1613 gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

1614 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1615 seats SMALLINT NOT NULL, 

1616 position CHAR(1), 

1617 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

1618 styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ 

1619 n INT NOT NULL,  

1620 street0VPIChance INT, 

1621 street0VPI INT, 

1622 street0AggrChance INT, 

1623 street0Aggr INT, 

1624 street0CalledRaiseChance INT, 

1625 street0CalledRaiseDone INT, 

1626 street0_2BChance INT, 

1627 street0_2BDone INT, 

1628 street0_3BChance INT, 

1629 street0_3BDone INT, 

1630 street0_4BChance INT, 

1631 street0_4BDone INT, 

1632 street0_C4BChance INT, 

1633 street0_C4BDone INT, 

1634 street0_FoldTo2BChance INT, 

1635 street0_FoldTo2BDone INT, 

1636 street0_FoldTo3BChance INT, 

1637 street0_FoldTo3BDone INT, 

1638 street0_FoldTo4BChance INT, 

1639 street0_FoldTo4BDone INT, 

1640 street0_SqueezeChance INT, 

1641 street0_SqueezeDone INT, 

1642 raiseToStealChance INT, 

1643 raiseToStealDone INT, 

1644 stealChance INT, 

1645 stealDone INT, 

1646 success_Steal INT, 

1647 street1Seen INT, 

1648 street2Seen INT, 

1649 street3Seen INT, 

1650 street4Seen INT, 

1651 sawShowdown INT,  

1652 street1Aggr INT, 

1653 street2Aggr INT, 

1654 street3Aggr INT, 

1655 street4Aggr INT, 

1656 otherRaisedStreet0 INT, 

1657 otherRaisedStreet1 INT, 

1658 otherRaisedStreet2 INT, 

1659 otherRaisedStreet3 INT, 

1660 otherRaisedStreet4 INT, 

1661 foldToOtherRaisedStreet0 INT, 

1662 foldToOtherRaisedStreet1 INT, 

1663 foldToOtherRaisedStreet2 INT, 

1664 foldToOtherRaisedStreet3 INT, 

1665 foldToOtherRaisedStreet4 INT, 

1666 wonWhenSeenStreet1 INT, 

1667 wonWhenSeenStreet2 INT, 

1668 wonWhenSeenStreet3 INT, 

1669 wonWhenSeenStreet4 INT, 

1670 wonAtSD INT,  

1671 raiseFirstInChance INT, 

1672 raisedFirstIn INT, 

1673 foldBbToStealChance INT, 

1674 foldedBbToSteal INT, 

1675 foldSbToStealChance INT, 

1676 foldedSbToSteal INT, 

1677 street1CBChance INT, 

1678 street1CBDone INT, 

1679 street2CBChance INT, 

1680 street2CBDone INT, 

1681 street3CBChance INT, 

1682 street3CBDone INT, 

1683 street4CBChance INT, 

1684 street4CBDone INT,  

1685 foldToStreet1CBChance INT, 

1686 foldToStreet1CBDone INT, 

1687 foldToStreet2CBChance INT, 

1688 foldToStreet2CBDone INT, 

1689 foldToStreet3CBChance INT, 

1690 foldToStreet3CBDone INT, 

1691 foldToStreet4CBChance INT, 

1692 foldToStreet4CBDone INT,  

1693 common BIGINT, 

1694 committed BIGINT, 

1695 winnings BIGINT, 

1696 rake BIGINT, 

1697 rakeDealt NUMERIC, 

1698 rakeContributed NUMERIC, 

1699 rakeWeighted NUMERIC, 

1700 totalProfit BIGINT, 

1701 allInEV NUMERIC, 

1702 showdownWinnings BIGINT, 

1703 nonShowdownWinnings BIGINT,  

1704 street1CheckCallRaiseChance INT, 

1705 street1CheckCallDone INT, 

1706 street1CheckRaiseDone INT, 

1707 street2CheckCallRaiseChance INT, 

1708 street2CheckCallDone INT, 

1709 street2CheckRaiseDone INT, 

1710 street3CheckCallRaiseChance INT, 

1711 street3CheckCallDone INT, 

1712 street3CheckRaiseDone INT, 

1713 street4CheckCallRaiseChance INT, 

1714 street4CheckCallDone INT, 

1715 street4CheckRaiseDone INT, 

1716 street0Calls INT, 

1717 street1Calls INT, 

1718 street2Calls INT, 

1719 street3Calls INT, 

1720 street4Calls INT, 

1721 street0Bets INT, 

1722 street1Bets INT, 

1723 street2Bets INT, 

1724 street3Bets INT, 

1725 street4Bets INT, 

1726 street0Raises INT, 

1727 street1Raises INT, 

1728 street2Raises INT, 

1729 street3Raises INT, 

1730 street4Raises INT,  

1731 street1Discards INT, 

1732 street2Discards INT, 

1733 street3Discards INT) 

1734 ENGINE=INNODB""" 

1735 elif db_server == "postgresql": 

1736 self.query["createHudCacheTable"] = """CREATE TABLE HudCache ( 

1737 id BIGSERIAL, PRIMARY KEY (id), 

1738 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

1739 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

1740 seats SMALLINT, 

1741 position CHAR(1), 

1742 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

1743 styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ 

1744 n INT,  

1745 street0VPIChance INT, 

1746 street0VPI INT, 

1747 street0AggrChance INT, 

1748 street0Aggr INT, 

1749 street0CalledRaiseChance INT, 

1750 street0CalledRaiseDone INT, 

1751 street0_2BChance INT, 

1752 street0_2BDone INT, 

1753 street0_3BChance INT, 

1754 street0_3BDone INT, 

1755 street0_4BChance INT, 

1756 street0_4BDone INT, 

1757 street0_C4BChance INT, 

1758 street0_C4BDone INT, 

1759 street0_FoldTo2BChance INT, 

1760 street0_FoldTo2BDone INT, 

1761 street0_FoldTo3BChance INT, 

1762 street0_FoldTo3BDone INT, 

1763 street0_FoldTo4BChance INT, 

1764 street0_FoldTo4BDone INT, 

1765 street0_SqueezeChance INT, 

1766 street0_SqueezeDone INT, 

1767 raiseToStealChance INT, 

1768 raiseToStealDone INT, 

1769 stealChance INT, 

1770 stealDone INT, 

1771 success_Steal INT, 

1772 street1Seen INT, 

1773 street2Seen INT, 

1774 street3Seen INT, 

1775 street4Seen INT, 

1776 sawShowdown INT, 

1777 street1Aggr INT, 

1778 street2Aggr INT, 

1779 street3Aggr INT, 

1780 street4Aggr INT, 

1781 otherRaisedStreet0 INT, 

1782 otherRaisedStreet1 INT, 

1783 otherRaisedStreet2 INT, 

1784 otherRaisedStreet3 INT, 

1785 otherRaisedStreet4 INT, 

1786 foldToOtherRaisedStreet0 INT, 

1787 foldToOtherRaisedStreet1 INT, 

1788 foldToOtherRaisedStreet2 INT, 

1789 foldToOtherRaisedStreet3 INT, 

1790 foldToOtherRaisedStreet4 INT, 

1791 wonWhenSeenStreet1 INT, 

1792 wonWhenSeenStreet2 INT, 

1793 wonWhenSeenStreet3 INT, 

1794 wonWhenSeenStreet4 INT, 

1795 wonAtSD INT, 

1796 raiseFirstInChance INT, 

1797 raisedFirstIn INT, 

1798 foldBbToStealChance INT, 

1799 foldedBbToSteal INT, 

1800 foldSbToStealChance INT, 

1801 foldedSbToSteal INT, 

1802 street1CBChance INT, 

1803 street1CBDone INT, 

1804 street2CBChance INT, 

1805 street2CBDone INT, 

1806 street3CBChance INT, 

1807 street3CBDone INT, 

1808 street4CBChance INT, 

1809 street4CBDone INT, 

1810 foldToStreet1CBChance INT, 

1811 foldToStreet1CBDone INT, 

1812 foldToStreet2CBChance INT, 

1813 foldToStreet2CBDone INT, 

1814 foldToStreet3CBChance INT, 

1815 foldToStreet3CBDone INT, 

1816 foldToStreet4CBChance INT, 

1817 foldToStreet4CBDone INT, 

1818 common BIGINT, 

1819 committed BIGINT, 

1820 winnings BIGINT, 

1821 rake BIGINT, 

1822 rakeDealt NUMERIC, 

1823 rakeContributed NUMERIC, 

1824 rakeWeighted NUMERIC, 

1825 totalProfit BIGINT, 

1826 allInEV NUMERIC, 

1827 showdownWinnings BIGINT, 

1828 nonShowdownWinnings BIGINT, 

1829 street1CheckCallRaiseChance INT, 

1830 street1CheckCallDone INT, 

1831 street1CheckRaiseDone INT, 

1832 street2CheckCallRaiseChance INT, 

1833 street2CheckCallDone INT, 

1834 street2CheckRaiseDone INT, 

1835 street3CheckCallRaiseChance INT, 

1836 street3CheckCallDone INT, 

1837 street3CheckRaiseDone INT, 

1838 street4CheckCallRaiseChance INT, 

1839 street4CheckCallDone INT, 

1840 street4CheckRaiseDone INT, 

1841 street0Calls INT, 

1842 street1Calls INT, 

1843 street2Calls INT, 

1844 street3Calls INT, 

1845 street4Calls INT, 

1846 street0Bets INT, 

1847 street1Bets INT, 

1848 street2Bets INT, 

1849 street3Bets INT, 

1850 street4Bets INT, 

1851 street0Raises INT, 

1852 street1Raises INT, 

1853 street2Raises INT, 

1854 street3Raises INT, 

1855 street4Raises INT, 

1856 street1Discards INT, 

1857 street2Discards INT, 

1858 street3Discards INT) 

1859 """ 

1860 elif db_server == "sqlite": 

1861 self.query["createHudCacheTable"] = """CREATE TABLE HudCache ( 

1862 id INTEGER PRIMARY KEY, 

1863 gametypeId INT, 

1864 playerId INT, 

1865 seats INT, 

1866 position TEXT, 

1867 tourneyTypeId INT, 

1868 styleKey TEXT NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ 

1869 n INT,  

1870 street0VPIChance INT, 

1871 street0VPI INT, 

1872 street0AggrChance INT, 

1873 street0Aggr INT, 

1874 street0CalledRaiseChance INT, 

1875 street0CalledRaiseDone INT, 

1876 street0_2BChance INT, 

1877 street0_2BDone INT, 

1878 street0_3BChance INT, 

1879 street0_3BDone INT, 

1880 street0_4BChance INT, 

1881 street0_4BDone INT, 

1882 street0_C4BChance INT, 

1883 street0_C4BDone INT, 

1884 street0_FoldTo2BChance INT, 

1885 street0_FoldTo2BDone INT, 

1886 street0_FoldTo3BChance INT, 

1887 street0_FoldTo3BDone INT, 

1888 street0_FoldTo4BChance INT, 

1889 street0_FoldTo4BDone INT, 

1890 street0_SqueezeChance INT, 

1891 street0_SqueezeDone INT, 

1892 raiseToStealChance INT, 

1893 raiseToStealDone INT, 

1894 stealChance INT, 

1895 stealDone INT, 

1896 success_Steal INT, 

1897 street1Seen INT, 

1898 street2Seen INT, 

1899 street3Seen INT, 

1900 street4Seen INT, 

1901 sawShowdown INT, 

1902 street1Aggr INT, 

1903 street2Aggr INT, 

1904 street3Aggr INT, 

1905 street4Aggr INT, 

1906 otherRaisedStreet0 INT, 

1907 otherRaisedStreet1 INT, 

1908 otherRaisedStreet2 INT, 

1909 otherRaisedStreet3 INT, 

1910 otherRaisedStreet4 INT, 

1911 foldToOtherRaisedStreet0 INT, 

1912 foldToOtherRaisedStreet1 INT, 

1913 foldToOtherRaisedStreet2 INT, 

1914 foldToOtherRaisedStreet3 INT, 

1915 foldToOtherRaisedStreet4 INT, 

1916 wonWhenSeenStreet1 INT, 

1917 wonWhenSeenStreet2 INT, 

1918 wonWhenSeenStreet3 INT, 

1919 wonWhenSeenStreet4 INT, 

1920 wonAtSD INT, 

1921 raiseFirstInChance INT, 

1922 raisedFirstIn INT, 

1923 foldBbToStealChance INT, 

1924 foldedBbToSteal INT, 

1925 foldSbToStealChance INT, 

1926 foldedSbToSteal INT, 

1927 street1CBChance INT, 

1928 street1CBDone INT, 

1929 street2CBChance INT, 

1930 street2CBDone INT, 

1931 street3CBChance INT, 

1932 street3CBDone INT, 

1933 street4CBChance INT, 

1934 street4CBDone INT, 

1935 foldToStreet1CBChance INT, 

1936 foldToStreet1CBDone INT, 

1937 foldToStreet2CBChance INT, 

1938 foldToStreet2CBDone INT, 

1939 foldToStreet3CBChance INT, 

1940 foldToStreet3CBDone INT, 

1941 foldToStreet4CBChance INT, 

1942 foldToStreet4CBDone INT, 

1943 common INT, 

1944 committed INT, 

1945 winnings INT, 

1946 rake INT, 

1947 rakeDealt decimal, 

1948 rakeContributed decimal, 

1949 rakeWeighted decimal, 

1950 totalProfit INT, 

1951 allInEV decimal, 

1952 showdownWinnings INT, 

1953 nonShowdownWinnings INT, 

1954 street1CheckCallRaiseChance INT, 

1955 street1CheckCallDone INT, 

1956 street1CheckRaiseDone INT, 

1957 street2CheckCallRaiseChance INT, 

1958 street2CheckCallDone INT, 

1959 street2CheckRaiseDone INT, 

1960 street3CheckCallRaiseChance INT, 

1961 street3CheckCallDone INT, 

1962 street3CheckRaiseDone INT, 

1963 street4CheckCallRaiseChance INT, 

1964 street4CheckCallDone INT, 

1965 street4CheckRaiseDone INT, 

1966 street0Calls INT, 

1967 street1Calls INT, 

1968 street2Calls INT, 

1969 street3Calls INT, 

1970 street4Calls INT, 

1971 street0Bets INT, 

1972 street1Bets INT, 

1973 street2Bets INT, 

1974 street3Bets INT, 

1975 street4Bets INT, 

1976 street0Raises INT, 

1977 street1Raises INT, 

1978 street2Raises INT, 

1979 street3Raises INT, 

1980 street4Raises INT, 

1981 street1Discards INT, 

1982 street2Discards INT, 

1983 street3Discards INT) 

1984 """ 

1985 

1986 ################################ 

1987 # Create CardsCache 

1988 ################################ 

1989 

1990 if db_server == "mysql": 

1991 self.query["createCardsCacheTable"] = """CREATE TABLE CardsCache ( 

1992 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

1993 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

1994 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id), 

1995 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

1996 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

1997 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

1998 startCards SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (startCards) REFERENCES StartCards(id), 

1999 n INT NOT NULL,  

2000 street0VPIChance INT, 

2001 street0VPI INT, 

2002 street0AggrChance INT, 

2003 street0Aggr INT, 

2004 street0CalledRaiseChance INT, 

2005 street0CalledRaiseDone INT, 

2006 street0_2BChance INT, 

2007 street0_2BDone INT, 

2008 street0_3BChance INT, 

2009 street0_3BDone INT, 

2010 street0_4BChance INT, 

2011 street0_4BDone INT, 

2012 street0_C4BChance INT, 

2013 street0_C4BDone INT, 

2014 street0_FoldTo2BChance INT, 

2015 street0_FoldTo2BDone INT, 

2016 street0_FoldTo3BChance INT, 

2017 street0_FoldTo3BDone INT, 

2018 street0_FoldTo4BChance INT, 

2019 street0_FoldTo4BDone INT, 

2020 street0_SqueezeChance INT, 

2021 street0_SqueezeDone INT, 

2022 raiseToStealChance INT, 

2023 raiseToStealDone INT, 

2024 stealChance INT, 

2025 stealDone INT, 

2026 success_Steal INT, 

2027 street1Seen INT, 

2028 street2Seen INT, 

2029 street3Seen INT, 

2030 street4Seen INT, 

2031 sawShowdown INT,  

2032 street1Aggr INT, 

2033 street2Aggr INT, 

2034 street3Aggr INT, 

2035 street4Aggr INT, 

2036 otherRaisedStreet0 INT, 

2037 otherRaisedStreet1 INT, 

2038 otherRaisedStreet2 INT, 

2039 otherRaisedStreet3 INT, 

2040 otherRaisedStreet4 INT, 

2041 foldToOtherRaisedStreet0 INT, 

2042 foldToOtherRaisedStreet1 INT, 

2043 foldToOtherRaisedStreet2 INT, 

2044 foldToOtherRaisedStreet3 INT, 

2045 foldToOtherRaisedStreet4 INT, 

2046 wonWhenSeenStreet1 INT, 

2047 wonWhenSeenStreet2 INT, 

2048 wonWhenSeenStreet3 INT, 

2049 wonWhenSeenStreet4 INT, 

2050 wonAtSD INT,  

2051 raiseFirstInChance INT, 

2052 raisedFirstIn INT, 

2053 foldBbToStealChance INT, 

2054 foldedBbToSteal INT, 

2055 foldSbToStealChance INT, 

2056 foldedSbToSteal INT, 

2057 street1CBChance INT, 

2058 street1CBDone INT, 

2059 street2CBChance INT, 

2060 street2CBDone INT, 

2061 street3CBChance INT, 

2062 street3CBDone INT, 

2063 street4CBChance INT, 

2064 street4CBDone INT,  

2065 foldToStreet1CBChance INT, 

2066 foldToStreet1CBDone INT, 

2067 foldToStreet2CBChance INT, 

2068 foldToStreet2CBDone INT, 

2069 foldToStreet3CBChance INT, 

2070 foldToStreet3CBDone INT, 

2071 foldToStreet4CBChance INT, 

2072 foldToStreet4CBDone INT,  

2073 common BIGINT, 

2074 committed BIGINT, 

2075 winnings BIGINT, 

2076 rake BIGINT, 

2077 rakeDealt NUMERIC, 

2078 rakeContributed NUMERIC, 

2079 rakeWeighted NUMERIC, 

2080 totalProfit BIGINT, 

2081 allInEV NUMERIC, 

2082 showdownWinnings BIGINT, 

2083 nonShowdownWinnings BIGINT,  

2084 street1CheckCallRaiseChance INT, 

2085 street1CheckCallDone INT, 

2086 street1CheckRaiseDone INT, 

2087 street2CheckCallRaiseChance INT, 

2088 street2CheckCallDone INT, 

2089 street2CheckRaiseDone INT, 

2090 street3CheckCallRaiseChance INT, 

2091 street3CheckCallDone INT, 

2092 street3CheckRaiseDone INT, 

2093 street4CheckCallRaiseChance INT, 

2094 street4CheckCallDone INT, 

2095 street4CheckRaiseDone INT, 

2096 street0Calls INT, 

2097 street1Calls INT, 

2098 street2Calls INT, 

2099 street3Calls INT, 

2100 street4Calls INT, 

2101 street0Bets INT, 

2102 street1Bets INT, 

2103 street2Bets INT, 

2104 street3Bets INT, 

2105 street4Bets INT, 

2106 street0Raises INT, 

2107 street1Raises INT, 

2108 street2Raises INT, 

2109 street3Raises INT, 

2110 street4Raises INT, 

2111 street1Discards INT, 

2112 street2Discards INT, 

2113 street3Discards INT) 

2114 ENGINE=INNODB""" 

2115 elif db_server == "postgresql": 

2116 self.query["createCardsCacheTable"] = """CREATE TABLE CardsCache ( 

2117 id BIGSERIAL, PRIMARY KEY (id), 

2118 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

2119 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id), 

2120 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

2121 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

2122 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

2123 startCards SMALLINT, FOREIGN KEY (startCards) REFERENCES StartCards(id), 

2124 n INT,  

2125 street0VPIChance INT, 

2126 street0VPI INT, 

2127 street0AggrChance INT, 

2128 street0Aggr INT, 

2129 street0CalledRaiseChance INT, 

2130 street0CalledRaiseDone INT, 

2131 street0_2BChance INT, 

2132 street0_2BDone INT, 

2133 street0_3BChance INT, 

2134 street0_3BDone INT, 

2135 street0_4BChance INT, 

2136 street0_4BDone INT, 

2137 street0_C4BChance INT, 

2138 street0_C4BDone INT, 

2139 street0_FoldTo2BChance INT, 

2140 street0_FoldTo2BDone INT, 

2141 street0_FoldTo3BChance INT, 

2142 street0_FoldTo3BDone INT, 

2143 street0_FoldTo4BChance INT, 

2144 street0_FoldTo4BDone INT, 

2145 street0_SqueezeChance INT, 

2146 street0_SqueezeDone INT, 

2147 raiseToStealChance INT, 

2148 raiseToStealDone INT, 

2149 stealChance INT, 

2150 stealDone INT, 

2151 success_Steal INT, 

2152 street1Seen INT, 

2153 street2Seen INT, 

2154 street3Seen INT, 

2155 street4Seen INT, 

2156 sawShowdown INT, 

2157 street1Aggr INT, 

2158 street2Aggr INT, 

2159 street3Aggr INT, 

2160 street4Aggr INT, 

2161 otherRaisedStreet0 INT, 

2162 otherRaisedStreet1 INT, 

2163 otherRaisedStreet2 INT, 

2164 otherRaisedStreet3 INT, 

2165 otherRaisedStreet4 INT, 

2166 foldToOtherRaisedStreet0 INT, 

2167 foldToOtherRaisedStreet1 INT, 

2168 foldToOtherRaisedStreet2 INT, 

2169 foldToOtherRaisedStreet3 INT, 

2170 foldToOtherRaisedStreet4 INT, 

2171 wonWhenSeenStreet1 INT, 

2172 wonWhenSeenStreet2 INT, 

2173 wonWhenSeenStreet3 INT, 

2174 wonWhenSeenStreet4 INT, 

2175 wonAtSD INT, 

2176 raiseFirstInChance INT, 

2177 raisedFirstIn INT, 

2178 foldBbToStealChance INT, 

2179 foldedBbToSteal INT, 

2180 foldSbToStealChance INT, 

2181 foldedSbToSteal INT, 

2182 street1CBChance INT, 

2183 street1CBDone INT, 

2184 street2CBChance INT, 

2185 street2CBDone INT, 

2186 street3CBChance INT, 

2187 street3CBDone INT, 

2188 street4CBChance INT, 

2189 street4CBDone INT, 

2190 foldToStreet1CBChance INT, 

2191 foldToStreet1CBDone INT, 

2192 foldToStreet2CBChance INT, 

2193 foldToStreet2CBDone INT, 

2194 foldToStreet3CBChance INT, 

2195 foldToStreet3CBDone INT, 

2196 foldToStreet4CBChance INT, 

2197 foldToStreet4CBDone INT, 

2198 common BIGINT, 

2199 committed BIGINT, 

2200 winnings BIGINT, 

2201 rake BIGINT, 

2202 rakeDealt NUMERIC, 

2203 rakeContributed NUMERIC, 

2204 rakeWeighted NUMERIC, 

2205 totalProfit BIGINT, 

2206 allInEV NUMERIC, 

2207 showdownWinnings BIGINT, 

2208 nonShowdownWinnings BIGINT, 

2209 street1CheckCallRaiseChance INT, 

2210 street1CheckCallDone INT, 

2211 street1CheckRaiseDone INT, 

2212 street2CheckCallRaiseChance INT, 

2213 street2CheckCallDone INT, 

2214 street2CheckRaiseDone INT, 

2215 street3CheckCallRaiseChance INT, 

2216 street3CheckCallDone INT, 

2217 street3CheckRaiseDone INT, 

2218 street4CheckCallRaiseChance INT, 

2219 street4CheckCallDone INT, 

2220 street4CheckRaiseDone INT, 

2221 street0Calls INT, 

2222 street1Calls INT, 

2223 street2Calls INT, 

2224 street3Calls INT, 

2225 street4Calls INT, 

2226 street0Bets INT, 

2227 street1Bets INT, 

2228 street2Bets INT, 

2229 street3Bets INT, 

2230 street4Bets INT, 

2231 street0Raises INT, 

2232 street1Raises INT, 

2233 street2Raises INT, 

2234 street3Raises INT, 

2235 street4Raises INT, 

2236 street1Discards INT, 

2237 street2Discards INT, 

2238 street3Discards INT) 

2239 """ 

2240 elif db_server == "sqlite": 

2241 self.query["createCardsCacheTable"] = """CREATE TABLE CardsCache ( 

2242 id INTEGER PRIMARY KEY, 

2243 weekId INT, 

2244 monthId INT, 

2245 gametypeId INT, 

2246 tourneyTypeId INT, 

2247 playerId INT, 

2248 startCards INT, 

2249 n INT,  

2250 street0VPIChance INT, 

2251 street0VPI INT, 

2252 street0AggrChance INT, 

2253 street0Aggr INT, 

2254 street0CalledRaiseChance INT, 

2255 street0CalledRaiseDone INT, 

2256 street0_2BChance INT, 

2257 street0_2BDone INT, 

2258 street0_3BChance INT, 

2259 street0_3BDone INT, 

2260 street0_4BChance INT, 

2261 street0_4BDone INT, 

2262 street0_C4BChance INT, 

2263 street0_C4BDone INT, 

2264 street0_FoldTo2BChance INT, 

2265 street0_FoldTo2BDone INT, 

2266 street0_FoldTo3BChance INT, 

2267 street0_FoldTo3BDone INT, 

2268 street0_FoldTo4BChance INT, 

2269 street0_FoldTo4BDone INT, 

2270 street0_SqueezeChance INT, 

2271 street0_SqueezeDone INT, 

2272 raiseToStealChance INT, 

2273 raiseToStealDone INT, 

2274 stealChance INT, 

2275 stealDone INT, 

2276 success_Steal INT, 

2277 street1Seen INT, 

2278 street2Seen INT, 

2279 street3Seen INT, 

2280 street4Seen INT, 

2281 sawShowdown INT, 

2282 street1Aggr INT, 

2283 street2Aggr INT, 

2284 street3Aggr INT, 

2285 street4Aggr INT, 

2286 otherRaisedStreet0 INT, 

2287 otherRaisedStreet1 INT, 

2288 otherRaisedStreet2 INT, 

2289 otherRaisedStreet3 INT, 

2290 otherRaisedStreet4 INT, 

2291 foldToOtherRaisedStreet0 INT, 

2292 foldToOtherRaisedStreet1 INT, 

2293 foldToOtherRaisedStreet2 INT, 

2294 foldToOtherRaisedStreet3 INT, 

2295 foldToOtherRaisedStreet4 INT, 

2296 wonWhenSeenStreet1 INT, 

2297 wonWhenSeenStreet2 INT, 

2298 wonWhenSeenStreet3 INT, 

2299 wonWhenSeenStreet4 INT, 

2300 wonAtSD INT, 

2301 raiseFirstInChance INT, 

2302 raisedFirstIn INT, 

2303 foldBbToStealChance INT, 

2304 foldedBbToSteal INT, 

2305 foldSbToStealChance INT, 

2306 foldedSbToSteal INT, 

2307 street1CBChance INT, 

2308 street1CBDone INT, 

2309 street2CBChance INT, 

2310 street2CBDone INT, 

2311 street3CBChance INT, 

2312 street3CBDone INT, 

2313 street4CBChance INT, 

2314 street4CBDone INT, 

2315 foldToStreet1CBChance INT, 

2316 foldToStreet1CBDone INT, 

2317 foldToStreet2CBChance INT, 

2318 foldToStreet2CBDone INT, 

2319 foldToStreet3CBChance INT, 

2320 foldToStreet3CBDone INT, 

2321 foldToStreet4CBChance INT, 

2322 foldToStreet4CBDone INT, 

2323 common INT, 

2324 committed INT, 

2325 winnings INT, 

2326 rake INT, 

2327 rakeDealt decimal, 

2328 rakeContributed decimal, 

2329 rakeWeighted decimal, 

2330 totalProfit INT, 

2331 allInEV decimal, 

2332 showdownWinnings INT, 

2333 nonShowdownWinnings INT, 

2334 street1CheckCallRaiseChance INT, 

2335 street1CheckCallDone INT, 

2336 street1CheckRaiseDone INT, 

2337 street2CheckCallRaiseChance INT, 

2338 street2CheckCallDone INT, 

2339 street2CheckRaiseDone INT, 

2340 street3CheckCallRaiseChance INT, 

2341 street3CheckCallDone INT, 

2342 street3CheckRaiseDone INT, 

2343 street4CheckCallRaiseChance INT, 

2344 street4CheckCallDone INT, 

2345 street4CheckRaiseDone INT, 

2346 street0Calls INT, 

2347 street1Calls INT, 

2348 street2Calls INT, 

2349 street3Calls INT, 

2350 street4Calls INT, 

2351 street0Bets INT, 

2352 street1Bets INT, 

2353 street2Bets INT, 

2354 street3Bets INT, 

2355 street4Bets INT, 

2356 street0Raises INT, 

2357 street1Raises INT, 

2358 street2Raises INT, 

2359 street3Raises INT, 

2360 street4Raises INT, 

2361 street1Discards INT, 

2362 street2Discards INT, 

2363 street3Discards INT) 

2364 """ 

2365 

2366 ################################ 

2367 # Create PositionsCache 

2368 ################################ 

2369 

2370 if db_server == "mysql": 

2371 self.query["createPositionsCacheTable"] = """CREATE TABLE PositionsCache ( 

2372 id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

2373 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

2374 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id), 

2375 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

2376 tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

2377 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

2378 seats SMALLINT NOT NULL, 

2379 maxPosition TINYINT NOT NULL, 

2380 position CHAR(1), 

2381 n INT NOT NULL,  

2382 street0VPIChance INT, 

2383 street0VPI INT, 

2384 street0AggrChance INT, 

2385 street0Aggr INT, 

2386 street0CalledRaiseChance INT, 

2387 street0CalledRaiseDone INT, 

2388 street0_2BChance INT, 

2389 street0_2BDone INT, 

2390 street0_3BChance INT, 

2391 street0_3BDone INT, 

2392 street0_4BChance INT, 

2393 street0_4BDone INT, 

2394 street0_C4BChance INT, 

2395 street0_C4BDone INT, 

2396 street0_FoldTo2BChance INT, 

2397 street0_FoldTo2BDone INT, 

2398 street0_FoldTo3BChance INT, 

2399 street0_FoldTo3BDone INT, 

2400 street0_FoldTo4BChance INT, 

2401 street0_FoldTo4BDone INT, 

2402 street0_SqueezeChance INT, 

2403 street0_SqueezeDone INT, 

2404 raiseToStealChance INT, 

2405 raiseToStealDone INT, 

2406 stealChance INT, 

2407 stealDone INT, 

2408 success_Steal INT, 

2409 street1Seen INT, 

2410 street2Seen INT, 

2411 street3Seen INT, 

2412 street4Seen INT, 

2413 sawShowdown INT,  

2414 street1Aggr INT, 

2415 street2Aggr INT, 

2416 street3Aggr INT, 

2417 street4Aggr INT, 

2418 otherRaisedStreet0 INT, 

2419 otherRaisedStreet1 INT, 

2420 otherRaisedStreet2 INT, 

2421 otherRaisedStreet3 INT, 

2422 otherRaisedStreet4 INT, 

2423 foldToOtherRaisedStreet0 INT, 

2424 foldToOtherRaisedStreet1 INT, 

2425 foldToOtherRaisedStreet2 INT, 

2426 foldToOtherRaisedStreet3 INT, 

2427 foldToOtherRaisedStreet4 INT, 

2428 wonWhenSeenStreet1 INT, 

2429 wonWhenSeenStreet2 INT, 

2430 wonWhenSeenStreet3 INT, 

2431 wonWhenSeenStreet4 INT, 

2432 wonAtSD INT,  

2433 raiseFirstInChance INT, 

2434 raisedFirstIn INT, 

2435 foldBbToStealChance INT, 

2436 foldedBbToSteal INT, 

2437 foldSbToStealChance INT, 

2438 foldedSbToSteal INT, 

2439 street1CBChance INT, 

2440 street1CBDone INT, 

2441 street2CBChance INT, 

2442 street2CBDone INT, 

2443 street3CBChance INT, 

2444 street3CBDone INT, 

2445 street4CBChance INT, 

2446 street4CBDone INT,  

2447 foldToStreet1CBChance INT, 

2448 foldToStreet1CBDone INT, 

2449 foldToStreet2CBChance INT, 

2450 foldToStreet2CBDone INT, 

2451 foldToStreet3CBChance INT, 

2452 foldToStreet3CBDone INT, 

2453 foldToStreet4CBChance INT, 

2454 foldToStreet4CBDone INT,  

2455 common BIGINT, 

2456 committed BIGINT, 

2457 winnings BIGINT, 

2458 rake BIGINT, 

2459 rakeDealt NUMERIC, 

2460 rakeContributed NUMERIC, 

2461 rakeWeighted NUMERIC, 

2462 totalProfit BIGINT, 

2463 allInEV NUMERIC, 

2464 showdownWinnings BIGINT, 

2465 nonShowdownWinnings BIGINT,  

2466 street1CheckCallRaiseChance INT, 

2467 street1CheckCallDone INT, 

2468 street1CheckRaiseDone INT, 

2469 street2CheckCallRaiseChance INT, 

2470 street2CheckCallDone INT, 

2471 street2CheckRaiseDone INT, 

2472 street3CheckCallRaiseChance INT, 

2473 street3CheckCallDone INT, 

2474 street3CheckRaiseDone INT, 

2475 street4CheckCallRaiseChance INT, 

2476 street4CheckCallDone INT, 

2477 street4CheckRaiseDone INT, 

2478 street0Calls INT, 

2479 street1Calls INT, 

2480 street2Calls INT, 

2481 street3Calls INT, 

2482 street4Calls INT, 

2483 street0Bets INT, 

2484 street1Bets INT, 

2485 street2Bets INT, 

2486 street3Bets INT, 

2487 street4Bets INT, 

2488 street0Raises INT, 

2489 street1Raises INT, 

2490 street2Raises INT, 

2491 street3Raises INT, 

2492 street4Raises INT, 

2493 street1Discards INT, 

2494 street2Discards INT, 

2495 street3Discards INT) 

2496 ENGINE=INNODB""" 

2497 elif db_server == "postgresql": 

2498 self.query["createPositionsCacheTable"] = """CREATE TABLE PositionsCache ( 

2499 id BIGSERIAL, PRIMARY KEY (id), 

2500 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

2501 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id), 

2502 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

2503 tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), 

2504 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

2505 seats SMALLINT, 

2506 maxPosition SMALLINT NOT NULL, 

2507 position CHAR(1), 

2508 n INT, 

2509 street0VPIChance INT, 

2510 street0VPI INT, 

2511 street0AggrChance INT, 

2512 street0Aggr INT, 

2513 street0CalledRaiseChance INT, 

2514 street0CalledRaiseDone INT, 

2515 street0_2BChance INT, 

2516 street0_2BDone INT, 

2517 street0_3BChance INT, 

2518 street0_3BDone INT, 

2519 street0_4BChance INT, 

2520 street0_4BDone INT, 

2521 street0_C4BChance INT, 

2522 street0_C4BDone INT, 

2523 street0_FoldTo2BChance INT, 

2524 street0_FoldTo2BDone INT, 

2525 street0_FoldTo3BChance INT, 

2526 street0_FoldTo3BDone INT, 

2527 street0_FoldTo4BChance INT, 

2528 street0_FoldTo4BDone INT, 

2529 street0_SqueezeChance INT, 

2530 street0_SqueezeDone INT, 

2531 raiseToStealChance INT, 

2532 raiseToStealDone INT, 

2533 stealChance INT, 

2534 stealDone INT, 

2535 success_Steal INT, 

2536 street1Seen INT, 

2537 street2Seen INT, 

2538 street3Seen INT, 

2539 street4Seen INT, 

2540 sawShowdown INT, 

2541 street1Aggr INT, 

2542 street2Aggr INT, 

2543 street3Aggr INT, 

2544 street4Aggr INT, 

2545 otherRaisedStreet0 INT, 

2546 otherRaisedStreet1 INT, 

2547 otherRaisedStreet2 INT, 

2548 otherRaisedStreet3 INT, 

2549 otherRaisedStreet4 INT, 

2550 foldToOtherRaisedStreet0 INT, 

2551 foldToOtherRaisedStreet1 INT, 

2552 foldToOtherRaisedStreet2 INT, 

2553 foldToOtherRaisedStreet3 INT, 

2554 foldToOtherRaisedStreet4 INT, 

2555 wonWhenSeenStreet1 INT, 

2556 wonWhenSeenStreet2 INT, 

2557 wonWhenSeenStreet3 INT, 

2558 wonWhenSeenStreet4 INT, 

2559 wonAtSD INT, 

2560 raiseFirstInChance INT, 

2561 raisedFirstIn INT, 

2562 foldBbToStealChance INT, 

2563 foldedBbToSteal INT, 

2564 foldSbToStealChance INT, 

2565 foldedSbToSteal INT, 

2566 street1CBChance INT, 

2567 street1CBDone INT, 

2568 street2CBChance INT, 

2569 street2CBDone INT, 

2570 street3CBChance INT, 

2571 street3CBDone INT, 

2572 street4CBChance INT, 

2573 street4CBDone INT, 

2574 foldToStreet1CBChance INT, 

2575 foldToStreet1CBDone INT, 

2576 foldToStreet2CBChance INT, 

2577 foldToStreet2CBDone INT, 

2578 foldToStreet3CBChance INT, 

2579 foldToStreet3CBDone INT, 

2580 foldToStreet4CBChance INT, 

2581 foldToStreet4CBDone INT, 

2582 common BIGINT, 

2583 committed BIGINT, 

2584 winnings BIGINT, 

2585 rake BIGINT, 

2586 rakeDealt NUMERIC, 

2587 rakeContributed NUMERIC, 

2588 rakeWeighted NUMERIC,  

2589 totalProfit BIGINT, 

2590 allInEV NUMERIC, 

2591 showdownWinnings BIGINT, 

2592 nonShowdownWinnings BIGINT, 

2593 street1CheckCallRaiseChance INT, 

2594 street1CheckCallDone INT, 

2595 street1CheckRaiseDone INT, 

2596 street2CheckCallRaiseChance INT, 

2597 street2CheckCallDone INT, 

2598 street2CheckRaiseDone INT, 

2599 street3CheckCallRaiseChance INT, 

2600 street3CheckCallDone INT, 

2601 street3CheckRaiseDone INT, 

2602 street4CheckCallRaiseChance INT, 

2603 street4CheckCallDone INT, 

2604 street4CheckRaiseDone INT, 

2605 street0Calls INT, 

2606 street1Calls INT, 

2607 street2Calls INT, 

2608 street3Calls INT, 

2609 street4Calls INT, 

2610 street0Bets INT, 

2611 street1Bets INT, 

2612 street2Bets INT, 

2613 street3Bets INT, 

2614 street4Bets INT, 

2615 street0Raises INT, 

2616 street1Raises INT, 

2617 street2Raises INT, 

2618 street3Raises INT, 

2619 street4Raises INT, 

2620 street1Discards INT, 

2621 street2Discards INT, 

2622 street3Discards INT) 

2623 """ 

2624 elif db_server == "sqlite": 

2625 self.query["createPositionsCacheTable"] = """CREATE TABLE PositionsCache ( 

2626 id INTEGER PRIMARY KEY, 

2627 weekId INT, 

2628 monthId INT, 

2629 gametypeId INT, 

2630 tourneyTypeId INT, 

2631 playerId INT, 

2632 seats INT, 

2633 maxPosition INT NOT NULL, 

2634 position TEXT, 

2635 n INT, 

2636 street0VPIChance INT, 

2637 street0VPI INT, 

2638 street0AggrChance INT, 

2639 street0Aggr INT, 

2640 street0CalledRaiseChance INT, 

2641 street0CalledRaiseDone INT, 

2642 street0_2BChance INT, 

2643 street0_2BDone INT, 

2644 street0_3BChance INT, 

2645 street0_3BDone INT, 

2646 street0_4BChance INT, 

2647 street0_4BDone INT, 

2648 street0_C4BChance INT, 

2649 street0_C4BDone INT, 

2650 street0_FoldTo2BChance INT, 

2651 street0_FoldTo2BDone INT, 

2652 street0_FoldTo3BChance INT, 

2653 street0_FoldTo3BDone INT, 

2654 street0_FoldTo4BChance INT, 

2655 street0_FoldTo4BDone INT, 

2656 street0_SqueezeChance INT, 

2657 street0_SqueezeDone INT, 

2658 raiseToStealChance INT, 

2659 raiseToStealDone INT, 

2660 stealChance INT, 

2661 stealDone INT, 

2662 success_Steal INT, 

2663 street1Seen INT, 

2664 street2Seen INT, 

2665 street3Seen INT, 

2666 street4Seen INT, 

2667 sawShowdown INT, 

2668 street1Aggr INT, 

2669 street2Aggr INT, 

2670 street3Aggr INT, 

2671 street4Aggr INT, 

2672 otherRaisedStreet0 INT, 

2673 otherRaisedStreet1 INT, 

2674 otherRaisedStreet2 INT, 

2675 otherRaisedStreet3 INT, 

2676 otherRaisedStreet4 INT, 

2677 foldToOtherRaisedStreet0 INT, 

2678 foldToOtherRaisedStreet1 INT, 

2679 foldToOtherRaisedStreet2 INT, 

2680 foldToOtherRaisedStreet3 INT, 

2681 foldToOtherRaisedStreet4 INT, 

2682 wonWhenSeenStreet1 INT, 

2683 wonWhenSeenStreet2 INT, 

2684 wonWhenSeenStreet3 INT, 

2685 wonWhenSeenStreet4 INT, 

2686 wonAtSD INT, 

2687 raiseFirstInChance INT, 

2688 raisedFirstIn INT, 

2689 foldBbToStealChance INT, 

2690 foldedBbToSteal INT, 

2691 foldSbToStealChance INT, 

2692 foldedSbToSteal INT, 

2693 street1CBChance INT, 

2694 street1CBDone INT, 

2695 street2CBChance INT, 

2696 street2CBDone INT, 

2697 street3CBChance INT, 

2698 street3CBDone INT, 

2699 street4CBChance INT, 

2700 street4CBDone INT, 

2701 foldToStreet1CBChance INT, 

2702 foldToStreet1CBDone INT, 

2703 foldToStreet2CBChance INT, 

2704 foldToStreet2CBDone INT, 

2705 foldToStreet3CBChance INT, 

2706 foldToStreet3CBDone INT, 

2707 foldToStreet4CBChance INT, 

2708 foldToStreet4CBDone INT, 

2709 common INT, 

2710 committed INT, 

2711 winnings INT, 

2712 rake INT, 

2713 rakeDealt decimal, 

2714 rakeContributed decimal, 

2715 rakeWeighted decimal, 

2716 totalProfit INT, 

2717 allInEV decimal, 

2718 showdownWinnings INT, 

2719 nonShowdownWinnings INT, 

2720 street1CheckCallRaiseChance INT, 

2721 street1CheckCallDone INT, 

2722 street1CheckRaiseDone INT, 

2723 street2CheckCallRaiseChance INT, 

2724 street2CheckCallDone INT, 

2725 street2CheckRaiseDone INT, 

2726 street3CheckCallRaiseChance INT, 

2727 street3CheckCallDone INT, 

2728 street3CheckRaiseDone INT, 

2729 street4CheckCallRaiseChance INT, 

2730 street4CheckCallDone INT, 

2731 street4CheckRaiseDone INT, 

2732 street0Calls INT, 

2733 street1Calls INT, 

2734 street2Calls INT, 

2735 street3Calls INT, 

2736 street4Calls INT, 

2737 street0Bets INT, 

2738 street1Bets INT, 

2739 street2Bets INT, 

2740 street3Bets INT, 

2741 street4Bets INT, 

2742 street0Raises INT, 

2743 street1Raises INT, 

2744 street2Raises INT, 

2745 street3Raises INT, 

2746 street4Raises INT, 

2747 street1Discards INT, 

2748 street2Discards INT, 

2749 street3Discards INT) 

2750 """ 

2751 

2752 ################################ 

2753 # Create Weeks 

2754 ################################ 

2755 

2756 if db_server == "mysql": 

2757 self.query["createWeeksTable"] = """CREATE TABLE Weeks ( 

2758 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

2759 weekStart DATETIME NOT NULL) 

2760 ENGINE=INNODB 

2761 """ 

2762 

2763 elif db_server == "postgresql": 

2764 self.query["createWeeksTable"] = """CREATE TABLE Weeks ( 

2765 id SERIAL, PRIMARY KEY (id), 

2766 weekStart timestamp without time zone NOT NULL) 

2767 """ 

2768 

2769 elif db_server == "sqlite": 

2770 self.query["createWeeksTable"] = """CREATE TABLE Weeks ( 

2771 id INTEGER PRIMARY KEY, 

2772 weekStart timestamp NOT NULL) 

2773 """ 

2774 

2775 ################################ 

2776 # Create Months 

2777 ################################ 

2778 

2779 if db_server == "mysql": 

2780 self.query["createMonthsTable"] = """CREATE TABLE Months ( 

2781 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

2782 monthStart DATETIME NOT NULL) 

2783 ENGINE=INNODB 

2784 """ 

2785 

2786 elif db_server == "postgresql": 

2787 self.query["createMonthsTable"] = """CREATE TABLE Months ( 

2788 id SERIAL, PRIMARY KEY (id), 

2789 monthStart timestamp without time zone NOT NULL) 

2790 """ 

2791 

2792 elif db_server == "sqlite": 

2793 self.query["createMonthsTable"] = """CREATE TABLE Months ( 

2794 id INTEGER PRIMARY KEY, 

2795 monthStart timestamp NOT NULL) 

2796 """ 

2797 

2798 ################################ 

2799 # Create Sessions 

2800 ################################ 

2801 

2802 if db_server == "mysql": 

2803 self.query["createSessionsTable"] = """CREATE TABLE Sessions ( 

2804 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

2805 weekId INT UNSIGNED, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

2806 monthId INT UNSIGNED, FOREIGN KEY (monthId) REFERENCES Months(id), 

2807 sessionStart DATETIME NOT NULL, 

2808 sessionEnd DATETIME NOT NULL) 

2809 ENGINE=INNODB 

2810 """ 

2811 

2812 elif db_server == "postgresql": 

2813 self.query["createSessionsTable"] = """CREATE TABLE Sessions ( 

2814 id SERIAL, PRIMARY KEY (id), 

2815 weekId INT, FOREIGN KEY (weekId) REFERENCES Weeks(id), 

2816 monthId INT, FOREIGN KEY (monthId) REFERENCES Months(id), 

2817 sessionStart timestamp without time zone NOT NULL, 

2818 sessionEnd timestamp without time zone NOT NULL) 

2819 """ 

2820 

2821 elif db_server == "sqlite": 

2822 self.query["createSessionsTable"] = """CREATE TABLE Sessions ( 

2823 id INTEGER PRIMARY KEY, 

2824 weekId INT, 

2825 monthId INT, 

2826 sessionStart timestamp NOT NULL, 

2827 sessionEnd timestamp NOT NULL) 

2828 """ 

2829 

2830 ################################ 

2831 # Create SessionsCache 

2832 ################################ 

2833 

2834 if db_server == "mysql": 

2835 self.query["createSessionsCacheTable"] = """CREATE TABLE SessionsCache ( 

2836 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

2837 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

2838 startTime DATETIME NOT NULL, 

2839 endTime DATETIME NOT NULL, 

2840 gametypeId SMALLINT UNSIGNED, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

2841 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

2842 n INT NOT NULL,  

2843 street0VPIChance INT, 

2844 street0VPI INT, 

2845 street0AggrChance INT, 

2846 street0Aggr INT, 

2847 street0CalledRaiseChance INT, 

2848 street0CalledRaiseDone INT, 

2849 street0_2BChance INT, 

2850 street0_2BDone INT, 

2851 street0_3BChance INT, 

2852 street0_3BDone INT, 

2853 street0_4BChance INT, 

2854 street0_4BDone INT, 

2855 street0_C4BChance INT, 

2856 street0_C4BDone INT, 

2857 street0_FoldTo2BChance INT, 

2858 street0_FoldTo2BDone INT, 

2859 street0_FoldTo3BChance INT, 

2860 street0_FoldTo3BDone INT, 

2861 street0_FoldTo4BChance INT, 

2862 street0_FoldTo4BDone INT, 

2863 street0_SqueezeChance INT, 

2864 street0_SqueezeDone INT, 

2865 raiseToStealChance INT, 

2866 raiseToStealDone INT, 

2867 stealChance INT, 

2868 stealDone INT, 

2869 success_Steal INT, 

2870 street1Seen INT, 

2871 street2Seen INT, 

2872 street3Seen INT, 

2873 street4Seen INT, 

2874 sawShowdown INT,  

2875 street1Aggr INT, 

2876 street2Aggr INT, 

2877 street3Aggr INT, 

2878 street4Aggr INT, 

2879 otherRaisedStreet0 INT, 

2880 otherRaisedStreet1 INT, 

2881 otherRaisedStreet2 INT, 

2882 otherRaisedStreet3 INT, 

2883 otherRaisedStreet4 INT, 

2884 foldToOtherRaisedStreet0 INT, 

2885 foldToOtherRaisedStreet1 INT, 

2886 foldToOtherRaisedStreet2 INT, 

2887 foldToOtherRaisedStreet3 INT, 

2888 foldToOtherRaisedStreet4 INT,  

2889 wonWhenSeenStreet1 INT, 

2890 wonWhenSeenStreet2 INT, 

2891 wonWhenSeenStreet3 INT, 

2892 wonWhenSeenStreet4 INT, 

2893 wonAtSD INT,  

2894 raiseFirstInChance INT, 

2895 raisedFirstIn INT, 

2896 foldBbToStealChance INT, 

2897 foldedBbToSteal INT, 

2898 foldSbToStealChance INT, 

2899 foldedSbToSteal INT, 

2900 street1CBChance INT, 

2901 street1CBDone INT, 

2902 street2CBChance INT, 

2903 street2CBDone INT, 

2904 street3CBChance INT, 

2905 street3CBDone INT, 

2906 street4CBChance INT, 

2907 street4CBDone INT,  

2908 foldToStreet1CBChance INT, 

2909 foldToStreet1CBDone INT, 

2910 foldToStreet2CBChance INT, 

2911 foldToStreet2CBDone INT, 

2912 foldToStreet3CBChance INT, 

2913 foldToStreet3CBDone INT, 

2914 foldToStreet4CBChance INT, 

2915 foldToStreet4CBDone INT,  

2916 common BIGINT, 

2917 committed BIGINT, 

2918 winnings BIGINT, 

2919 rake BIGINT, 

2920 rakeDealt NUMERIC, 

2921 rakeContributed NUMERIC, 

2922 rakeWeighted NUMERIC, 

2923 totalProfit BIGINT, 

2924 allInEV NUMERIC, 

2925 showdownWinnings BIGINT, 

2926 nonShowdownWinnings BIGINT,  

2927 street1CheckCallRaiseChance INT, 

2928 street1CheckCallDone INT, 

2929 street1CheckRaiseDone INT, 

2930 street2CheckCallRaiseChance INT, 

2931 street2CheckCallDone INT, 

2932 street2CheckRaiseDone INT, 

2933 street3CheckCallRaiseChance INT, 

2934 street3CheckCallDone INT, 

2935 street3CheckRaiseDone INT, 

2936 street4CheckCallRaiseChance INT, 

2937 street4CheckCallDone INT, 

2938 street4CheckRaiseDone INT, 

2939 street0Calls INT, 

2940 street1Calls INT, 

2941 street2Calls INT, 

2942 street3Calls INT, 

2943 street4Calls INT, 

2944 street0Bets INT, 

2945 street1Bets INT, 

2946 street2Bets INT, 

2947 street3Bets INT, 

2948 street4Bets INT, 

2949 street0Raises INT, 

2950 street1Raises INT, 

2951 street2Raises INT, 

2952 street3Raises INT, 

2953 street4Raises INT, 

2954 street1Discards INT, 

2955 street2Discards INT, 

2956 street3Discards INT) 

2957 ENGINE=INNODB 

2958 """ 

2959 

2960 elif db_server == "postgresql": 

2961 self.query["createSessionsCacheTable"] = """CREATE TABLE SessionsCache ( 

2962 id SERIAL, PRIMARY KEY (id), 

2963 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

2964 startTime timestamp without time zone NOT NULL, 

2965 endTime timestamp without time zone NOT NULL, 

2966 gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), 

2967 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

2968 n INT,  

2969 street0VPIChance INT, 

2970 street0VPI INT, 

2971 street0AggrChance INT, 

2972 street0Aggr INT, 

2973 street0CalledRaiseChance INT, 

2974 street0CalledRaiseDone INT, 

2975 street0_2BChance INT, 

2976 street0_2BDone INT, 

2977 street0_3BChance INT, 

2978 street0_3BDone INT, 

2979 street0_4BChance INT, 

2980 street0_4BDone INT, 

2981 street0_C4BChance INT, 

2982 street0_C4BDone INT, 

2983 street0_FoldTo2BChance INT, 

2984 street0_FoldTo2BDone INT, 

2985 street0_FoldTo3BChance INT, 

2986 street0_FoldTo3BDone INT, 

2987 street0_FoldTo4BChance INT, 

2988 street0_FoldTo4BDone INT, 

2989 street0_SqueezeChance INT, 

2990 street0_SqueezeDone INT, 

2991 raiseToStealChance INT, 

2992 raiseToStealDone INT, 

2993 stealChance INT, 

2994 stealDone INT, 

2995 success_Steal INT, 

2996 street1Seen INT, 

2997 street2Seen INT, 

2998 street3Seen INT, 

2999 street4Seen INT, 

3000 sawShowdown INT, 

3001 street1Aggr INT, 

3002 street2Aggr INT, 

3003 street3Aggr INT, 

3004 street4Aggr INT, 

3005 otherRaisedStreet0 INT, 

3006 otherRaisedStreet1 INT, 

3007 otherRaisedStreet2 INT, 

3008 otherRaisedStreet3 INT, 

3009 otherRaisedStreet4 INT, 

3010 foldToOtherRaisedStreet0 INT, 

3011 foldToOtherRaisedStreet1 INT, 

3012 foldToOtherRaisedStreet2 INT, 

3013 foldToOtherRaisedStreet3 INT, 

3014 foldToOtherRaisedStreet4 INT,  

3015 wonWhenSeenStreet1 INT, 

3016 wonWhenSeenStreet2 INT, 

3017 wonWhenSeenStreet3 INT, 

3018 wonWhenSeenStreet4 INT, 

3019 wonAtSD INT, 

3020 raiseFirstInChance INT, 

3021 raisedFirstIn INT, 

3022 foldBbToStealChance INT, 

3023 foldedBbToSteal INT, 

3024 foldSbToStealChance INT, 

3025 foldedSbToSteal INT, 

3026 street1CBChance INT, 

3027 street1CBDone INT, 

3028 street2CBChance INT, 

3029 street2CBDone INT, 

3030 street3CBChance INT, 

3031 street3CBDone INT, 

3032 street4CBChance INT, 

3033 street4CBDone INT, 

3034 foldToStreet1CBChance INT, 

3035 foldToStreet1CBDone INT, 

3036 foldToStreet2CBChance INT, 

3037 foldToStreet2CBDone INT, 

3038 foldToStreet3CBChance INT, 

3039 foldToStreet3CBDone INT, 

3040 foldToStreet4CBChance INT, 

3041 foldToStreet4CBDone INT, 

3042 common BIGINT, 

3043 committed BIGINT, 

3044 winnings BIGINT, 

3045 rake BIGINT, 

3046 rakeDealt NUMERIC, 

3047 rakeContributed NUMERIC, 

3048 rakeWeighted NUMERIC, 

3049 totalProfit BIGINT, 

3050 allInEV NUMERIC, 

3051 showdownWinnings BIGINT, 

3052 nonShowdownWinnings BIGINT, 

3053 street1CheckCallRaiseChance INT, 

3054 street1CheckCallDone INT, 

3055 street1CheckRaiseDone INT, 

3056 street2CheckCallRaiseChance INT, 

3057 street2CheckCallDone INT, 

3058 street2CheckRaiseDone INT, 

3059 street3CheckCallRaiseChance INT, 

3060 street3CheckCallDone INT, 

3061 street3CheckRaiseDone INT, 

3062 street4CheckCallRaiseChance INT, 

3063 street4CheckCallDone INT, 

3064 street4CheckRaiseDone INT, 

3065 street0Calls INT, 

3066 street1Calls INT, 

3067 street2Calls INT, 

3068 street3Calls INT, 

3069 street4Calls INT, 

3070 street0Bets INT, 

3071 street1Bets INT, 

3072 street2Bets INT, 

3073 street3Bets INT, 

3074 street4Bets INT, 

3075 street0Raises INT, 

3076 street1Raises INT, 

3077 street2Raises INT, 

3078 street3Raises INT, 

3079 street4Raises INT, 

3080 street1Discards INT, 

3081 street2Discards INT, 

3082 street3Discards INT) 

3083 """ 

3084 

3085 elif db_server == "sqlite": 

3086 self.query["createSessionsCacheTable"] = """CREATE TABLE SessionsCache ( 

3087 id INTEGER PRIMARY KEY, 

3088 sessionId INT, 

3089 startTime timestamp NOT NULL, 

3090 endTime timestamp NOT NULL, 

3091 gametypeId INT, 

3092 playerId INT, 

3093 n INT, 

3094 street0VPIChance INT, 

3095 street0VPI INT, 

3096 street0AggrChance INT, 

3097 street0Aggr INT, 

3098 street0CalledRaiseChance INT, 

3099 street0CalledRaiseDone INT, 

3100 street0_2BChance INT, 

3101 street0_2BDone INT, 

3102 street0_3BChance INT, 

3103 street0_3BDone INT, 

3104 street0_4BChance INT, 

3105 street0_4BDone INT, 

3106 street0_C4BChance INT, 

3107 street0_C4BDone INT, 

3108 street0_FoldTo2BChance INT, 

3109 street0_FoldTo2BDone INT, 

3110 street0_FoldTo3BChance INT, 

3111 street0_FoldTo3BDone INT, 

3112 street0_FoldTo4BChance INT, 

3113 street0_FoldTo4BDone INT, 

3114 street0_SqueezeChance INT, 

3115 street0_SqueezeDone INT, 

3116 raiseToStealChance INT, 

3117 raiseToStealDone INT, 

3118 stealChance INT, 

3119 stealDone INT, 

3120 success_Steal INT, 

3121 street1Seen INT, 

3122 street2Seen INT, 

3123 street3Seen INT, 

3124 street4Seen INT, 

3125 sawShowdown INT, 

3126 street1Aggr INT, 

3127 street2Aggr INT, 

3128 street3Aggr INT, 

3129 street4Aggr INT, 

3130 otherRaisedStreet0 INT, 

3131 otherRaisedStreet1 INT, 

3132 otherRaisedStreet2 INT, 

3133 otherRaisedStreet3 INT, 

3134 otherRaisedStreet4 INT, 

3135 foldToOtherRaisedStreet0 INT, 

3136 foldToOtherRaisedStreet1 INT, 

3137 foldToOtherRaisedStreet2 INT, 

3138 foldToOtherRaisedStreet3 INT, 

3139 foldToOtherRaisedStreet4 INT,  

3140 wonWhenSeenStreet1 INT, 

3141 wonWhenSeenStreet2 INT, 

3142 wonWhenSeenStreet3 INT, 

3143 wonWhenSeenStreet4 INT, 

3144 wonAtSD INT, 

3145 raiseFirstInChance INT, 

3146 raisedFirstIn INT, 

3147 foldBbToStealChance INT, 

3148 foldedBbToSteal INT, 

3149 foldSbToStealChance INT, 

3150 foldedSbToSteal INT, 

3151 street1CBChance INT, 

3152 street1CBDone INT, 

3153 street2CBChance INT, 

3154 street2CBDone INT, 

3155 street3CBChance INT, 

3156 street3CBDone INT, 

3157 street4CBChance INT, 

3158 street4CBDone INT, 

3159 foldToStreet1CBChance INT, 

3160 foldToStreet1CBDone INT, 

3161 foldToStreet2CBChance INT, 

3162 foldToStreet2CBDone INT, 

3163 foldToStreet3CBChance INT, 

3164 foldToStreet3CBDone INT, 

3165 foldToStreet4CBChance INT, 

3166 foldToStreet4CBDone INT, 

3167 common INT, 

3168 committed INT, 

3169 winnings INT, 

3170 rake INT, 

3171 rakeDealt decimal, 

3172 rakeContributed decimal, 

3173 rakeWeighted decimal, 

3174 totalProfit INT, 

3175 allInEV decimal, 

3176 showdownWinnings INT, 

3177 nonShowdownWinnings INT, 

3178 street1CheckCallRaiseChance INT, 

3179 street1CheckCallDone INT, 

3180 street1CheckRaiseDone INT, 

3181 street2CheckCallRaiseChance INT, 

3182 street2CheckCallDone INT, 

3183 street2CheckRaiseDone INT, 

3184 street3CheckCallRaiseChance INT, 

3185 street3CheckCallDone INT, 

3186 street3CheckRaiseDone INT, 

3187 street4CheckCallRaiseChance INT, 

3188 street4CheckCallDone INT, 

3189 street4CheckRaiseDone INT, 

3190 street0Calls INT, 

3191 street1Calls INT, 

3192 street2Calls INT, 

3193 street3Calls INT, 

3194 street4Calls INT, 

3195 street0Bets INT, 

3196 street1Bets INT, 

3197 street2Bets INT, 

3198 street3Bets INT, 

3199 street4Bets INT, 

3200 street0Raises INT, 

3201 street1Raises INT, 

3202 street2Raises INT, 

3203 street3Raises INT, 

3204 street4Raises INT, 

3205 street1Discards INT, 

3206 street2Discards INT, 

3207 street3Discards INT) 

3208 """ 

3209 

3210 ################################ 

3211 # Create TourneysCache 

3212 ################################ 

3213 

3214 if db_server == "mysql": 

3215 self.query["createTourneysCacheTable"] = """CREATE TABLE TourneysCache ( 

3216 id INT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id), 

3217 sessionId INT UNSIGNED, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

3218 startTime DATETIME NOT NULL, 

3219 endTime DATETIME NOT NULL, 

3220 tourneyId INT UNSIGNED NOT NULL, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

3221 playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), 

3222 n INT NOT NULL,  

3223 street0VPIChance INT, 

3224 street0VPI INT, 

3225 street0AggrChance INT, 

3226 street0Aggr INT, 

3227 street0CalledRaiseChance INT, 

3228 street0CalledRaiseDone INT, 

3229 street0_2BChance INT, 

3230 street0_2BDone INT, 

3231 street0_3BChance INT, 

3232 street0_3BDone INT, 

3233 street0_4BChance INT, 

3234 street0_4BDone INT, 

3235 street0_C4BChance INT, 

3236 street0_C4BDone INT, 

3237 street0_FoldTo2BChance INT, 

3238 street0_FoldTo2BDone INT, 

3239 street0_FoldTo3BChance INT, 

3240 street0_FoldTo3BDone INT, 

3241 street0_FoldTo4BChance INT, 

3242 street0_FoldTo4BDone INT, 

3243 street0_SqueezeChance INT, 

3244 street0_SqueezeDone INT, 

3245 raiseToStealChance INT, 

3246 raiseToStealDone INT, 

3247 stealChance INT, 

3248 stealDone INT, 

3249 success_Steal INT, 

3250 street1Seen INT, 

3251 street2Seen INT, 

3252 street3Seen INT, 

3253 street4Seen INT, 

3254 sawShowdown INT,  

3255 street1Aggr INT, 

3256 street2Aggr INT, 

3257 street3Aggr INT, 

3258 street4Aggr INT, 

3259 otherRaisedStreet0 INT, 

3260 otherRaisedStreet1 INT, 

3261 otherRaisedStreet2 INT, 

3262 otherRaisedStreet3 INT, 

3263 otherRaisedStreet4 INT, 

3264 foldToOtherRaisedStreet0 INT, 

3265 foldToOtherRaisedStreet1 INT, 

3266 foldToOtherRaisedStreet2 INT, 

3267 foldToOtherRaisedStreet3 INT, 

3268 foldToOtherRaisedStreet4 INT,  

3269 wonWhenSeenStreet1 INT, 

3270 wonWhenSeenStreet2 INT, 

3271 wonWhenSeenStreet3 INT, 

3272 wonWhenSeenStreet4 INT, 

3273 wonAtSD INT,  

3274 raiseFirstInChance INT, 

3275 raisedFirstIn INT, 

3276 foldBbToStealChance INT, 

3277 foldedBbToSteal INT, 

3278 foldSbToStealChance INT, 

3279 foldedSbToSteal INT, 

3280 street1CBChance INT, 

3281 street1CBDone INT, 

3282 street2CBChance INT, 

3283 street2CBDone INT, 

3284 street3CBChance INT, 

3285 street3CBDone INT, 

3286 street4CBChance INT, 

3287 street4CBDone INT,  

3288 foldToStreet1CBChance INT, 

3289 foldToStreet1CBDone INT, 

3290 foldToStreet2CBChance INT, 

3291 foldToStreet2CBDone INT, 

3292 foldToStreet3CBChance INT, 

3293 foldToStreet3CBDone INT, 

3294 foldToStreet4CBChance INT, 

3295 foldToStreet4CBDone INT,  

3296 common BIGINT, 

3297 committed BIGINT, 

3298 winnings BIGINT, 

3299 rake BIGINT, 

3300 rakeDealt NUMERIC, 

3301 rakeContributed NUMERIC, 

3302 rakeWeighted NUMERIC, 

3303 totalProfit BIGINT, 

3304 allInEV NUMERIC, 

3305 showdownWinnings BIGINT, 

3306 nonShowdownWinnings BIGINT,  

3307 street1CheckCallRaiseChance INT, 

3308 street1CheckCallDone INT, 

3309 street1CheckRaiseDone INT, 

3310 street2CheckCallRaiseChance INT, 

3311 street2CheckCallDone INT, 

3312 street2CheckRaiseDone INT, 

3313 street3CheckCallRaiseChance INT, 

3314 street3CheckCallDone INT, 

3315 street3CheckRaiseDone INT, 

3316 street4CheckCallRaiseChance INT, 

3317 street4CheckCallDone INT, 

3318 street4CheckRaiseDone INT, 

3319 street0Calls INT, 

3320 street1Calls INT, 

3321 street2Calls INT, 

3322 street3Calls INT, 

3323 street4Calls INT, 

3324 street0Bets INT, 

3325 street1Bets INT, 

3326 street2Bets INT, 

3327 street3Bets INT, 

3328 street4Bets INT, 

3329 street0Raises INT, 

3330 street1Raises INT, 

3331 street2Raises INT, 

3332 street3Raises INT, 

3333 street4Raises INT, 

3334 street1Discards INT, 

3335 street2Discards INT, 

3336 street3Discards INT) 

3337 ENGINE=INNODB 

3338 """ 

3339 

3340 elif db_server == "postgresql": 

3341 self.query["createTourneysCacheTable"] = """CREATE TABLE TourneysCache ( 

3342 id SERIAL, PRIMARY KEY (id), 

3343 sessionId INT, FOREIGN KEY (sessionId) REFERENCES Sessions(id), 

3344 startTime timestamp without time zone NOT NULL, 

3345 endTime timestamp without time zone NOT NULL, 

3346 tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id), 

3347 playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), 

3348 n INT,  

3349 street0VPIChance INT, 

3350 street0VPI INT, 

3351 street0AggrChance INT, 

3352 street0Aggr INT, 

3353 street0CalledRaiseChance INT, 

3354 street0CalledRaiseDone INT, 

3355 street0_2BChance INT, 

3356 street0_2BDone INT, 

3357 street0_3BChance INT, 

3358 street0_3BDone INT, 

3359 street0_4BChance INT, 

3360 street0_4BDone INT, 

3361 street0_C4BChance INT, 

3362 street0_C4BDone INT, 

3363 street0_FoldTo2BChance INT, 

3364 street0_FoldTo2BDone INT, 

3365 street0_FoldTo3BChance INT, 

3366 street0_FoldTo3BDone INT, 

3367 street0_FoldTo4BChance INT, 

3368 street0_FoldTo4BDone INT, 

3369 street0_SqueezeChance INT, 

3370 street0_SqueezeDone INT, 

3371 raiseToStealChance INT, 

3372 raiseToStealDone INT, 

3373 stealChance INT, 

3374 stealDone INT, 

3375 success_Steal INT, 

3376 street1Seen INT, 

3377 street2Seen INT, 

3378 street3Seen INT, 

3379 street4Seen INT, 

3380 sawShowdown INT, 

3381 street1Aggr INT, 

3382 street2Aggr INT, 

3383 street3Aggr INT, 

3384 street4Aggr INT, 

3385 otherRaisedStreet0 INT, 

3386 otherRaisedStreet1 INT, 

3387 otherRaisedStreet2 INT, 

3388 otherRaisedStreet3 INT, 

3389 otherRaisedStreet4 INT, 

3390 foldToOtherRaisedStreet0 INT, 

3391 foldToOtherRaisedStreet1 INT, 

3392 foldToOtherRaisedStreet2 INT, 

3393 foldToOtherRaisedStreet3 INT, 

3394 foldToOtherRaisedStreet4 INT,  

3395 wonWhenSeenStreet1 INT, 

3396 wonWhenSeenStreet2 INT, 

3397 wonWhenSeenStreet3 INT, 

3398 wonWhenSeenStreet4 INT, 

3399 wonAtSD INT, 

3400 raiseFirstInChance INT, 

3401 raisedFirstIn INT, 

3402 foldBbToStealChance INT, 

3403 foldedBbToSteal INT, 

3404 foldSbToStealChance INT, 

3405 foldedSbToSteal INT, 

3406 street1CBChance INT, 

3407 street1CBDone INT, 

3408 street2CBChance INT, 

3409 street2CBDone INT, 

3410 street3CBChance INT, 

3411 street3CBDone INT, 

3412 street4CBChance INT, 

3413 street4CBDone INT, 

3414 foldToStreet1CBChance INT, 

3415 foldToStreet1CBDone INT, 

3416 foldToStreet2CBChance INT, 

3417 foldToStreet2CBDone INT, 

3418 foldToStreet3CBChance INT, 

3419 foldToStreet3CBDone INT, 

3420 foldToStreet4CBChance INT, 

3421 foldToStreet4CBDone INT, 

3422 common BIGINT, 

3423 committed BIGINT, 

3424 winnings BIGINT, 

3425 rake BIGINT, 

3426 rakeDealt NUMERIC, 

3427 rakeContributed NUMERIC, 

3428 rakeWeighted NUMERIC, 

3429 totalProfit BIGINT, 

3430 allInEV NUMERIC, 

3431 showdownWinnings BIGINT, 

3432 nonShowdownWinnings BIGINT, 

3433 street1CheckCallRaiseChance INT, 

3434 street1CheckCallDone INT, 

3435 street1CheckRaiseDone INT, 

3436 street2CheckCallRaiseChance INT, 

3437 street2CheckCallDone INT, 

3438 street2CheckRaiseDone INT, 

3439 street3CheckCallRaiseChance INT, 

3440 street3CheckCallDone INT, 

3441 street3CheckRaiseDone INT, 

3442 street4CheckCallRaiseChance INT, 

3443 street4CheckCallDone INT, 

3444 street4CheckRaiseDone INT, 

3445 street0Calls INT, 

3446 street1Calls INT, 

3447 street2Calls INT, 

3448 street3Calls INT, 

3449 street4Calls INT, 

3450 street0Bets INT, 

3451 street1Bets INT, 

3452 street2Bets INT, 

3453 street3Bets INT, 

3454 street4Bets INT, 

3455 street0Raises INT, 

3456 street1Raises INT, 

3457 street2Raises INT, 

3458 street3Raises INT, 

3459 street4Raises INT, 

3460 street1Discards INT, 

3461 street2Discards INT, 

3462 street3Discards INT) 

3463 """ 

3464 

3465 elif db_server == "sqlite": 

3466 self.query["createTourneysCacheTable"] = """CREATE TABLE TourneysCache ( 

3467 id INTEGER PRIMARY KEY, 

3468 sessionId INT, 

3469 startTime timestamp NOT NULL, 

3470 endTime timestamp NOT NULL, 

3471 tourneyId INT, 

3472 playerId INT, 

3473 n INT, 

3474 street0VPIChance INT, 

3475 street0VPI INT, 

3476 street0AggrChance INT, 

3477 street0Aggr INT, 

3478 street0CalledRaiseChance INT, 

3479 street0CalledRaiseDone INT, 

3480 street0_2BChance INT, 

3481 street0_2BDone INT, 

3482 street0_3BChance INT, 

3483 street0_3BDone INT, 

3484 street0_4BChance INT, 

3485 street0_4BDone INT, 

3486 street0_C4BChance INT, 

3487 street0_C4BDone INT, 

3488 street0_FoldTo2BChance INT, 

3489 street0_FoldTo2BDone INT, 

3490 street0_FoldTo3BChance INT, 

3491 street0_FoldTo3BDone INT, 

3492 street0_FoldTo4BChance INT, 

3493 street0_FoldTo4BDone INT, 

3494 street0_SqueezeChance INT, 

3495 street0_SqueezeDone INT, 

3496 raiseToStealChance INT, 

3497 raiseToStealDone INT, 

3498 stealChance INT, 

3499 stealDone INT, 

3500 success_Steal INT, 

3501 street1Seen INT, 

3502 street2Seen INT, 

3503 street3Seen INT, 

3504 street4Seen INT, 

3505 sawShowdown INT, 

3506 street1Aggr INT, 

3507 street2Aggr INT, 

3508 street3Aggr INT, 

3509 street4Aggr INT, 

3510 otherRaisedStreet0 INT, 

3511 otherRaisedStreet1 INT, 

3512 otherRaisedStreet2 INT, 

3513 otherRaisedStreet3 INT, 

3514 otherRaisedStreet4 INT, 

3515 foldToOtherRaisedStreet0 INT, 

3516 foldToOtherRaisedStreet1 INT, 

3517 foldToOtherRaisedStreet2 INT, 

3518 foldToOtherRaisedStreet3 INT, 

3519 foldToOtherRaisedStreet4 INT,  

3520 wonWhenSeenStreet1 INT, 

3521 wonWhenSeenStreet2 INT, 

3522 wonWhenSeenStreet3 INT, 

3523 wonWhenSeenStreet4 INT, 

3524 wonAtSD INT, 

3525 raiseFirstInChance INT, 

3526 raisedFirstIn INT, 

3527 foldBbToStealChance INT, 

3528 foldedBbToSteal INT, 

3529 foldSbToStealChance INT, 

3530 foldedSbToSteal INT, 

3531 street1CBChance INT, 

3532 street1CBDone INT, 

3533 street2CBChance INT, 

3534 street2CBDone INT, 

3535 street3CBChance INT, 

3536 street3CBDone INT, 

3537 street4CBChance INT, 

3538 street4CBDone INT, 

3539 foldToStreet1CBChance INT, 

3540 foldToStreet1CBDone INT, 

3541 foldToStreet2CBChance INT, 

3542 foldToStreet2CBDone INT, 

3543 foldToStreet3CBChance INT, 

3544 foldToStreet3CBDone INT, 

3545 foldToStreet4CBChance INT, 

3546 foldToStreet4CBDone INT, 

3547 common INT, 

3548 committed INT, 

3549 winnings INT, 

3550 rake INT, 

3551 rakeDealt decimal, 

3552 rakeContributed decimal, 

3553 rakeWeighted decimal, 

3554 totalProfit INT, 

3555 allInEV decimal, 

3556 showdownWinnings INT, 

3557 nonShowdownWinnings INT, 

3558 street1CheckCallRaiseChance INT, 

3559 street1CheckCallDone INT, 

3560 street1CheckRaiseDone INT, 

3561 street2CheckCallRaiseChance INT, 

3562 street2CheckCallDone INT, 

3563 street2CheckRaiseDone INT, 

3564 street3CheckCallRaiseChance INT, 

3565 street3CheckCallDone INT, 

3566 street3CheckRaiseDone INT, 

3567 street4CheckCallRaiseChance INT, 

3568 street4CheckCallDone INT, 

3569 street4CheckRaiseDone INT, 

3570 street0Calls INT, 

3571 street1Calls INT, 

3572 street2Calls INT, 

3573 street3Calls INT, 

3574 street4Calls INT, 

3575 street0Bets INT, 

3576 street1Bets INT, 

3577 street2Bets INT, 

3578 street3Bets INT, 

3579 street4Bets INT, 

3580 street0Raises INT, 

3581 street1Raises INT, 

3582 street2Raises INT, 

3583 street3Raises INT, 

3584 street4Raises INT, 

3585 street1Discards INT, 

3586 street2Discards INT, 

3587 street3Discards INT) 

3588 """ 

3589 

3590 if db_server == "mysql": 

3591 self.query["addTourneyIndex"] = ( 

3592 """ALTER TABLE Tourneys ADD UNIQUE INDEX siteTourneyNo(siteTourneyNo, tourneyTypeId)""" 

3593 ) 

3594 elif db_server == "postgresql": 

3595 self.query["addTourneyIndex"] = ( 

3596 """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)""" 

3597 ) 

3598 elif db_server == "sqlite": 

3599 self.query["addTourneyIndex"] = ( 

3600 """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)""" 

3601 ) 

3602 

3603 if db_server == "mysql": 

3604 self.query["addHandsIndex"] = ( 

3605 """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gametypeId<heroseat>)""" 

3606 ) 

3607 elif db_server == "postgresql": 

3608 self.query["addHandsIndex"] = ( 

3609 """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId<heroseat>)""" 

3610 ) 

3611 elif db_server == "sqlite": 

3612 self.query["addHandsIndex"] = ( 

3613 """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId<heroseat>)""" 

3614 ) 

3615 

3616 if db_server == "mysql": 

3617 self.query["addPlayersSeat"] = ( 

3618 """ALTER TABLE HandsPlayers ADD UNIQUE INDEX playerSeat_idx(handId, seatNo)""" 

3619 ) 

3620 elif db_server == "postgresql": 

3621 self.query["addPlayersSeat"] = """CREATE UNIQUE INDEX playerSeat_idx ON HandsPlayers (handId, seatNo)""" 

3622 elif db_server == "sqlite": 

3623 self.query["addPlayersSeat"] = """CREATE UNIQUE INDEX playerSeat_idx ON HandsPlayers (handId, seatNo)""" 

3624 

3625 if db_server == "mysql": 

3626 self.query["addHeroSeat"] = """ALTER TABLE Hands ADD UNIQUE INDEX heroSeat_idx(id, heroSeat)""" 

3627 elif db_server == "postgresql": 

3628 self.query["addHeroSeat"] = """CREATE UNIQUE INDEX heroSeat_idx ON Hands (id, heroSeat)""" 

3629 elif db_server == "sqlite": 

3630 self.query["addHeroSeat"] = """CREATE UNIQUE INDEX heroSeat_idx ON Hands (id, heroSeat)""" 

3631 

3632 if db_server == "mysql": 

3633 self.query["addHandsPlayersSeat"] = ( 

3634 """ALTER TABLE HandsPlayers ADD UNIQUE INDEX handsPlayerSeat_idx(handId, seatNo)""" 

3635 ) 

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

3640 

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

3647 

3648 if db_server == "mysql": 

3649 self.query["addTPlayersIndex"] = ( 

3650 """ALTER TABLE TourneysPlayers ADD UNIQUE INDEX _tourneyId(tourneyId, playerId, entryId)""" 

3651 ) 

3652 elif db_server == "postgresql": 

3653 self.query["addTPlayersIndex"] = ( 

3654 """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId, entryId)""" 

3655 ) 

3656 elif db_server == "sqlite": 

3657 self.query["addTPlayersIndex"] = ( 

3658 """CREATE UNIQUE INDEX tourneyId ON TourneysPlayers (tourneyId, playerId, entryId)""" 

3659 ) 

3660 

3661 if db_server == "mysql": 

3662 self.query["addStartCardsIndex"] = """ALTER TABLE StartCards ADD UNIQUE INDEX cards_idx (category, rank)""" 

3663 elif db_server == "postgresql": 

3664 self.query["addStartCardsIndex"] = """CREATE UNIQUE INDEX cards_idx ON StartCards (category, rank)""" 

3665 elif db_server == "sqlite": 

3666 self.query["addStartCardsIndex"] = """CREATE UNIQUE INDEX cards_idx ON StartCards (category, rank)""" 

3667 

3668 if db_server == "mysql": 

3669 self.query["addSeatsIndex"] = """ALTER TABLE Hands ADD INDEX seats_idx (seats)""" 

3670 elif db_server == "postgresql": 

3671 self.query["addSeatsIndex"] = """CREATE INDEX seats_idx ON Hands (seats)""" 

3672 elif db_server == "sqlite": 

3673 self.query["addSeatsIndex"] = """CREATE INDEX seats_idx ON Hands (seats)""" 

3674 

3675 if db_server == "mysql": 

3676 self.query["addPositionIndex"] = """ALTER TABLE HandsPlayers ADD INDEX position_idx (position)""" 

3677 elif db_server == "postgresql": 

3678 self.query["addPositionIndex"] = """CREATE INDEX position_idx ON HandsPlayers (position)""" 

3679 elif db_server == "sqlite": 

3680 self.query["addPositionIndex"] = """CREATE INDEX position_idx ON HandsPlayers (position)""" 

3681 

3682 if db_server == "mysql": 

3683 self.query["addStartCashIndex"] = """ALTER TABLE HandsPlayers ADD INDEX cash_idx (startCash)""" 

3684 elif db_server == "postgresql": 

3685 self.query["addStartCashIndex"] = """CREATE INDEX cash_idx ON HandsPlayers (startCash)""" 

3686 elif db_server == "sqlite": 

3687 self.query["addStartCashIndex"] = """CREATE INDEX cash_idx ON HandsPlayers (startCash)""" 

3688 

3689 if db_server == "mysql": 

3690 self.query["addEffStackIndex"] = """ALTER TABLE HandsPlayers ADD INDEX eff_stack_idx (effStack)""" 

3691 elif db_server == "postgresql": 

3692 self.query["addEffStackIndex"] = """CREATE INDEX eff_stack_idx ON HandsPlayers (effStack)""" 

3693 elif db_server == "sqlite": 

3694 self.query["addEffStackIndex"] = """CREATE INDEX eff_stack_idx ON HandsPlayers (effStack)""" 

3695 

3696 if db_server == "mysql": 

3697 self.query["addTotalProfitIndex"] = """ALTER TABLE HandsPlayers ADD INDEX profit_idx (totalProfit)""" 

3698 elif db_server == "postgresql": 

3699 self.query["addTotalProfitIndex"] = """CREATE INDEX profit_idx ON HandsPlayers (totalProfit)""" 

3700 elif db_server == "sqlite": 

3701 self.query["addTotalProfitIndex"] = """CREATE INDEX profit_idx ON HandsPlayers (totalProfit)""" 

3702 

3703 if db_server == "mysql": 

3704 self.query["addWinningsIndex"] = """ALTER TABLE HandsPlayers ADD INDEX winnings_idx (winnings)""" 

3705 elif db_server == "postgresql": 

3706 self.query["addWinningsIndex"] = """CREATE INDEX winnings_idx ON HandsPlayers (winnings)""" 

3707 elif db_server == "sqlite": 

3708 self.query["addWinningsIndex"] = """CREATE INDEX winnings_idx ON HandsPlayers (winnings)""" 

3709 

3710 if db_server == "mysql": 

3711 self.query["addFinalPotIndex"] = """ALTER TABLE Hands ADD INDEX pot_idx (finalPot)""" 

3712 elif db_server == "postgresql": 

3713 self.query["addFinalPotIndex"] = """CREATE INDEX pot_idx ON Hands (finalPot)""" 

3714 elif db_server == "sqlite": 

3715 self.query["addFinalPotIndex"] = """CREATE INDEX pot_idx ON Hands (finalPot)""" 

3716 

3717 if db_server == "mysql": 

3718 self.query["addStreetIndex"] = """ALTER TABLE HandsStove ADD INDEX street_idx (streetId, boardId)""" 

3719 elif db_server == "postgresql": 

3720 self.query["addStreetIndex"] = """CREATE INDEX street_idx ON HandsStove (streetId, boardId)""" 

3721 elif db_server == "sqlite": 

3722 self.query["addStreetIndex"] = """CREATE INDEX street_idx ON HandsStove (streetId, boardId)""" 

3723 

3724 self.query["addSessionsCacheCompundIndex"] = ( 

3725 """CREATE INDEX SessionsCache_Compound_idx ON SessionsCache(gametypeId, playerId)""" 

3726 ) 

3727 self.query["addTourneysCacheCompundIndex"] = ( 

3728 """CREATE UNIQUE INDEX TourneysCache_Compound_idx ON TourneysCache(tourneyId, playerId)""" 

3729 ) 

3730 self.query["addHudCacheCompundIndex"] = ( 

3731 """CREATE UNIQUE INDEX HudCache_Compound_idx ON HudCache(gametypeId, playerId, seats, position, tourneyTypeId, styleKey)""" 

3732 ) 

3733 

3734 self.query["addCardsCacheCompundIndex"] = ( 

3735 """CREATE UNIQUE INDEX CardsCache_Compound_idx ON CardsCache(weekId, monthId, gametypeId, tourneyTypeId, playerId, startCards)""" 

3736 ) 

3737 self.query["addPositionsCacheCompundIndex"] = ( 

3738 """CREATE UNIQUE INDEX PositionsCache_Compound_idx ON PositionsCache(weekId, monthId, gametypeId, tourneyTypeId, playerId, seats, maxPosition, position)""" 

3739 ) 

3740 

3741 # (left(file, 255)) is not valid syntax on postgres psycopg2 on windows (postgres v8.4) 

3742 # error thrown is HINT: "No function matches the given name and argument types. You might need to add explicit type casts." 

3743 # so we will just create the index with the full filename. 

3744 if db_server == "mysql": 

3745 self.query["addFilesIndex"] = """CREATE UNIQUE INDEX index_file ON Files (file(255))""" 

3746 elif db_server == "postgresql": 

3747 self.query["addFilesIndex"] = """CREATE UNIQUE INDEX index_file ON Files (file)""" 

3748 elif db_server == "sqlite": 

3749 self.query["addFilesIndex"] = """CREATE UNIQUE INDEX index_file ON Files (file)""" 

3750 

3751 self.query["addTableNameIndex"] = """CREATE INDEX index_tableName ON Hands (tableName)""" 

3752 self.query["addPlayerNameIndex"] = """CREATE INDEX index_playerName ON Players (name)""" 

3753 self.query["addPlayerHeroesIndex"] = """CREATE INDEX player_heroes ON Players (hero)""" 

3754 

3755 self.query["get_last_hand"] = "select max(id) from Hands" 

3756 

3757 self.query["get_last_date"] = "SELECT MAX(startTime) FROM Hands" 

3758 

3759 self.query["get_first_date"] = "SELECT MIN(startTime) FROM Hands" 

3760 

3761 self.query["get_player_id"] = """ 

3762 select Players.id AS player_id  

3763 from Players, Sites 

3764 where Players.name = %s 

3765 and Sites.name = %s 

3766 and Players.siteId = Sites.id 

3767 """ 

3768 

3769 self.query["get_player_names"] = """ 

3770 select p.name 

3771 from Players p 

3772 where lower(p.name) like lower(%s) 

3773 and (p.siteId = %s or %s = -1) 

3774 """ 

3775 

3776 self.query["get_gameinfo_from_hid"] = """ 

3777 SELECT 

3778 s.name, 

3779 g.category, 

3780 g.base, 

3781 g.type, 

3782 g.limitType, 

3783 g.hilo, 

3784 round(g.smallBlind / 100.0,2), 

3785 round(g.bigBlind / 100.0,2), 

3786 round(g.smallBet / 100.0,2), 

3787 round(g.bigBet / 100.0,2), 

3788 g.currency, 

3789 h.gametypeId, 

3790 g.split 

3791 FROM 

3792 Hands as h, 

3793 Sites as s, 

3794 Gametypes as g, 

3795 HandsPlayers as hp, 

3796 Players as p 

3797 WHERE 

3798 h.id = %s 

3799 and g.id = h.gametypeId 

3800 and hp.handId = h.id 

3801 and p.id = hp.playerId 

3802 and s.id = p.siteId 

3803 limit 1 

3804 """ 

3805 

3806 self.query["get_stats_from_hand"] = """ 

3807 SELECT hc.playerId AS player_id, 

3808 hp.seatNo AS seat, 

3809 p.name AS screen_name, 

3810 sum(hc.n) AS n, 

3811 sum(hc.street0VPIChance) AS vpip_opp, 

3812 sum(hc.street0VPI) AS vpip, 

3813 sum(hc.street0AggrChance) AS pfr_opp, 

3814 sum(hc.street0Aggr) AS pfr, 

3815 sum(hc.street0CalledRaiseChance) AS CAR_opp_0, 

3816 sum(hc.street0CalledRaiseDone) AS CAR_0, 

3817 sum(hc.street0_3BChance) AS TB_opp_0, 

3818 sum(hc.street0_3BDone) AS TB_0, 

3819 sum(hc.street0_4BChance) AS FB_opp_0, 

3820 sum(hc.street0_4BDone) AS FB_0, 

3821 sum(hc.street0_C4BChance) AS CFB_opp_0, 

3822 sum(hc.street0_C4BDone) AS CFB_0, 

3823 sum(hc.street0_FoldTo3BChance) AS F3B_opp_0, 

3824 sum(hc.street0_FoldTo3BDone) AS F3B_0, 

3825 sum(hc.street0_FoldTo4BChance) AS F4B_opp_0, 

3826 sum(hc.street0_FoldTo4BDone) AS F4B_0, 

3827 sum(hc.street0_SqueezeChance) AS SQZ_opp_0, 

3828 sum(hc.street0_SqueezeDone) AS SQZ_0, 

3829 sum(hc.raiseToStealChance) AS RTS_opp, 

3830 sum(hc.raiseToStealDone) AS RTS, 

3831 sum(hc.success_Steal) AS SUC_ST, 

3832 sum(hc.street1Seen) AS saw_f, 

3833 sum(hc.street1Seen) AS saw_1, 

3834 sum(hc.street2Seen) AS saw_2, 

3835 sum(hc.street3Seen) AS saw_3, 

3836 sum(hc.street4Seen) AS saw_4, 

3837 sum(hc.sawShowdown) AS sd, 

3838 sum(hc.street1Aggr) AS aggr_1, 

3839 sum(hc.street2Aggr) AS aggr_2, 

3840 sum(hc.street3Aggr) AS aggr_3, 

3841 sum(hc.street4Aggr) AS aggr_4, 

3842 sum(hc.otherRaisedStreet1) AS was_raised_1, 

3843 sum(hc.otherRaisedStreet2) AS was_raised_2, 

3844 sum(hc.otherRaisedStreet3) AS was_raised_3, 

3845 sum(hc.otherRaisedStreet4) AS was_raised_4, 

3846 sum(hc.foldToOtherRaisedStreet1) AS f_freq_1, 

3847 sum(hc.foldToOtherRaisedStreet2) AS f_freq_2, 

3848 sum(hc.foldToOtherRaisedStreet3) AS f_freq_3, 

3849 sum(hc.foldToOtherRaisedStreet4) AS f_freq_4, 

3850 sum(hc.wonWhenSeenStreet1) AS w_w_s_1, 

3851 sum(hc.wonAtSD) AS wmsd, 

3852 sum(hc.stealChance) AS steal_opp, 

3853 sum(hc.stealDone) AS steal, 

3854 sum(hc.foldSbToStealChance) AS SBstolen, 

3855 sum(hc.foldedSbToSteal) AS SBnotDef, 

3856 sum(hc.foldBbToStealChance) AS BBstolen, 

3857 sum(hc.foldedBbToSteal) AS BBnotDef, 

3858 sum(hc.street1CBChance) AS CB_opp_1, 

3859 sum(hc.street1CBDone) AS CB_1, 

3860 sum(hc.street2CBChance) AS CB_opp_2, 

3861 sum(hc.street2CBDone) AS CB_2, 

3862 sum(hc.street3CBChance) AS CB_opp_3, 

3863 sum(hc.street3CBDone) AS CB_3, 

3864 sum(hc.street4CBChance) AS CB_opp_4, 

3865 sum(hc.street4CBDone) AS CB_4, 

3866 sum(hc.foldToStreet1CBChance) AS f_cb_opp_1, 

3867 sum(hc.foldToStreet1CBDone) AS f_cb_1, 

3868 sum(hc.foldToStreet2CBChance) AS f_cb_opp_2, 

3869 sum(hc.foldToStreet2CBDone) AS f_cb_2, 

3870 sum(hc.foldToStreet3CBChance) AS f_cb_opp_3, 

3871 sum(hc.foldToStreet3CBDone) AS f_cb_3, 

3872 sum(hc.foldToStreet4CBChance) AS f_cb_opp_4, 

3873 sum(hc.foldToStreet4CBDone) AS f_cb_4, 

3874 sum(hc.totalProfit) AS net, 

3875 sum(gt.bigblind * hc.n) AS bigblind, 

3876 sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1, 

3877 sum(hc.street1CheckCallDone) AS cc_1, 

3878 sum(hc.street1CheckRaiseDone) AS cr_1, 

3879 sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2, 

3880 sum(hc.street2CheckCallDone) AS cc_2, 

3881 sum(hc.street2CheckRaiseDone) AS cr_2, 

3882 sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3, 

3883 sum(hc.street3CheckCallDone) AS cc_3, 

3884 sum(hc.street3CheckRaiseDone) AS cr_3, 

3885 sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4, 

3886 sum(hc.street4CheckCallDone) AS cc_4 

3887 sum(hc.street4CheckRaiseDone) AS cr_4 

3888 sum(hc.street0Calls) AS call_0, 

3889 sum(hc.street1Calls) AS call_1, 

3890 sum(hc.street2Calls) AS call_2, 

3891 sum(hc.street3Calls) AS call_3, 

3892 sum(hc.street4Calls) AS call_4, 

3893 sum(hc.street0Bets) AS bet_0, 

3894 sum(hc.street1Bets) AS bet_1, 

3895 sum(hc.street2Bets) AS bet_2, 

3896 sum(hc.street3Bets) AS bet_3, 

3897 sum(hc.street4Bets) AS bet_4, 

3898 sum(hc.street0Raises) AS raise_0, 

3899 sum(hc.street1Raises) AS raise_1, 

3900 sum(hc.street2Raises) AS raise_2, 

3901 sum(hc.street3Raises) AS raise_3, 

3902 sum(hc.street4Raises) AS raise_4 

3903 FROM Hands h 

3904 INNER JOIN HandsPlayers hp ON (hp.handId = h.id) 

3905 INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0 

3906 AND hc.gametypeId+0 = h.gametypeId+0) 

3907 INNER JOIN Players p ON (p.id = hp.PlayerId+0) 

3908 INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId) 

3909 WHERE h.id = %s 

3910 AND hc.styleKey > %s 

3911 /* styleKey is currently 'd' (for date) followed by a yyyymmdd 

3912 date key. Set it to 0000000 or similar to get all records */ 

3913 /* also check activeseats here even if only 3 groups eg 2-3/4-6/7+  

3914 e.g. could use a multiplier: 

3915 AND h.seats > X / 1.25 and hp.seats < X * 1.25 

3916 where X is the number of active players at the current table (and 

3917 1.25 would be a config value so user could change it) 

3918 */ 

3919 GROUP BY hc.PlayerId, hp.seatNo, p.name 

3920 ORDER BY hc.PlayerId, hp.seatNo, p.name 

3921 """ 

3922 

3923 # same as above except stats are aggregated for all blind/limit levels 

3924 self.query["get_stats_from_hand_aggregated"] = """ 

3925 /* explain query plan */ 

3926 SELECT hc.playerId AS player_id, 

3927 max(case when hc.gametypeId = h.gametypeId 

3928 then hp.seatNo 

3929 else -1 

3930 end) AS seat, 

3931 p.name AS screen_name, 

3932 sum(hc.n) AS n, 

3933 sum(hc.street0VPIChance) AS vpip_opp, 

3934 sum(hc.street0VPI) AS vpip, 

3935 sum(hc.street0AggrChance) AS pfr_opp, 

3936 sum(hc.street0Aggr) AS pfr, 

3937 sum(hc.street0CalledRaiseChance) AS CAR_opp_0, 

3938 sum(hc.street0CalledRaiseDone) AS CAR_0, 

3939 sum(hc.street0_3BChance) AS TB_opp_0, 

3940 sum(hc.street0_3BDone) AS TB_0, 

3941 sum(hc.street0_4BChance) AS FB_opp_0, 

3942 sum(hc.street0_4BDone) AS FB_0, 

3943 sum(hc.street0_C4BChance) AS CFB_opp_0, 

3944 sum(hc.street0_C4BDone) AS CFB_0, 

3945 sum(hc.street0_FoldTo3BChance) AS F3B_opp_0, 

3946 sum(hc.street0_FoldTo3BDone) AS F3B_0, 

3947 sum(hc.street0_FoldTo4BChance) AS F4B_opp_0, 

3948 sum(hc.street0_FoldTo4BDone) AS F4B_0, 

3949 sum(hc.street0_SqueezeChance) AS SQZ_opp_0, 

3950 sum(hc.street0_SqueezeDone) AS SQZ_0, 

3951 sum(hc.raiseToStealChance) AS RTS_opp, 

3952 sum(hc.raiseToStealDone) AS RTS, 

3953 sum(hc.success_Steal) AS SUC_ST, 

3954 sum(hc.street1Seen) AS saw_f, 

3955 sum(hc.street1Seen) AS saw_1, 

3956 sum(hc.street2Seen) AS saw_2, 

3957 sum(hc.street3Seen) AS saw_3, 

3958 sum(hc.street4Seen) AS saw_4, 

3959 sum(hc.sawShowdown) AS sd, 

3960 sum(hc.street1Aggr) AS aggr_1, 

3961 sum(hc.street2Aggr) AS aggr_2, 

3962 sum(hc.street3Aggr) AS aggr_3, 

3963 sum(hc.street4Aggr) AS aggr_4, 

3964 sum(hc.otherRaisedStreet1) AS was_raised_1, 

3965 sum(hc.otherRaisedStreet2) AS was_raised_2, 

3966 sum(hc.otherRaisedStreet3) AS was_raised_3, 

3967 sum(hc.otherRaisedStreet4) AS was_raised_4, 

3968 sum(hc.foldToOtherRaisedStreet1) AS f_freq_1, 

3969 sum(hc.foldToOtherRaisedStreet2) AS f_freq_2, 

3970 sum(hc.foldToOtherRaisedStreet3) AS f_freq_3, 

3971 sum(hc.foldToOtherRaisedStreet4) AS f_freq_4, 

3972 sum(hc.wonWhenSeenStreet1) AS w_w_s_1, 

3973 sum(hc.wonAtSD) AS wmsd, 

3974 sum(hc.stealChance) AS steal_opp, 

3975 sum(hc.stealDone) AS steal, 

3976 sum(hc.foldSbToStealChance) AS SBstolen, 

3977 sum(hc.foldedSbToSteal) AS SBnotDef, 

3978 sum(hc.foldBbToStealChance) AS BBstolen, 

3979 sum(hc.foldedBbToSteal) AS BBnotDef, 

3980 sum(hc.street1CBChance) AS CB_opp_1, 

3981 sum(hc.street1CBDone) AS CB_1, 

3982 sum(hc.street2CBChance) AS CB_opp_2, 

3983 sum(hc.street2CBDone) AS CB_2, 

3984 sum(hc.street3CBChance) AS CB_opp_3, 

3985 sum(hc.street3CBDone) AS CB_3, 

3986 sum(hc.street4CBChance) AS CB_opp_4, 

3987 sum(hc.street4CBDone) AS CB_4, 

3988 sum(hc.foldToStreet1CBChance) AS f_cb_opp_1, 

3989 sum(hc.foldToStreet1CBDone) AS f_cb_1, 

3990 sum(hc.foldToStreet2CBChance) AS f_cb_opp_2, 

3991 sum(hc.foldToStreet2CBDone) AS f_cb_2, 

3992 sum(hc.foldToStreet3CBChance) AS f_cb_opp_3, 

3993 sum(hc.foldToStreet3CBDone) AS f_cb_3, 

3994 sum(hc.foldToStreet4CBChance) AS f_cb_opp_4, 

3995 sum(hc.foldToStreet4CBDone) AS f_cb_4, 

3996 sum(hc.totalProfit) AS net, 

3997 sum(gt.bigblind * hc.n) AS bigblind, 

3998 sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1, 

3999 sum(hc.street1CheckCallDone) AS cc_1, 

4000 sum(hc.street1CheckRaiseDone) AS cr_1, 

4001 sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2, 

4002 sum(hc.street2CheckCallDone) AS cc_2, 

4003 sum(hc.street2CheckRaiseDone) AS cr_2, 

4004 sum(hc.street3CheckCallRaiseChance) AS ccr_opp_3, 

4005 sum(hc.street3CheckCallDone) AS cc_3, 

4006 sum(hc.street3CheckRaiseDone) AS cr_3, 

4007 sum(hc.street4CheckCallRaiseChance) AS ccr_opp_4, 

4008 sum(hc.street4CheckCallDone) AS cc_4, 

4009 sum(hc.street4CheckRaiseDone) AS cr_4, 

4010 sum(hc.street0Calls) AS call_0, 

4011 sum(hc.street1Calls) AS call_1, 

4012 sum(hc.street2Calls) AS call_2, 

4013 sum(hc.street3Calls) AS call_3, 

4014 sum(hc.street4Calls) AS call_4, 

4015 sum(hc.street0Bets) AS bet_0, 

4016 sum(hc.street1Bets) AS bet_1, 

4017 sum(hc.street2Bets) AS bet_2, 

4018 sum(hc.street3Bets) AS bet_3, 

4019 sum(hc.street4Bets) AS bet_4, 

4020 sum(hc.street0Raises) AS raise_0, 

4021 sum(hc.street1Raises) AS raise_1, 

4022 sum(hc.street2Raises) AS raise_2, 

4023 sum(hc.street3Raises) AS raise_3, 

4024 sum(hc.street4Raises) AS raise_4 

4025 FROM Hands h 

4026 INNER JOIN HandsPlayers hp ON (hp.handId = h.id) 

4027 INNER JOIN HudCache hc ON (hc.playerId = hp.playerId) 

4028 INNER JOIN Players p ON (p.id = hc.playerId) 

4029 INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId) 

4030 WHERE h.id = %s 

4031 AND ( /* 2 separate parts for hero and opponents */ 

4032 ( hp.playerId != %s 

4033 AND hc.styleKey > %s 

4034 AND hc.gametypeId+0 in 

4035 (SELECT gt1.id from Gametypes gt1, Gametypes gt2 

4036 WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */ 

4037 AND gt1.type = gt2.type /* ring/tourney */ 

4038 AND gt1.category = gt2.category /* holdem/stud*/ 

4039 AND gt1.limittype = gt2.limittype /* fl/nl */ 

4040 AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */ 

4041 AND gt1.bigblind >= gt2.bigblind / %s 

4042 AND gt2.id = %s) 

4043 AND hc.seats between %s and %s 

4044 ) 

4045 OR 

4046 ( hp.playerId = %s 

4047 AND hc.styleKey > %s 

4048 AND hc.gametypeId+0 in 

4049 (SELECT gt1.id from Gametypes gt1, Gametypes gt2 

4050 WHERE gt1.siteid = gt2.siteid /* find gametypes where these match: */ 

4051 AND gt1.type = gt2.type /* ring/tourney */ 

4052 AND gt1.category = gt2.category /* holdem/stud*/ 

4053 AND gt1.limittype = gt2.limittype /* fl/nl */ 

4054 AND gt1.bigblind <= gt2.bigblind * %s /* bigblind similar size */ 

4055 AND gt1.bigblind >= gt2.bigblind / %s 

4056 AND gt2.id = %s) 

4057 AND hc.seats between %s and %s 

4058 ) 

4059 ) 

4060 GROUP BY hc.PlayerId, p.name 

4061 ORDER BY hc.PlayerId, p.name 

4062 """ 

4063 # NOTES on above cursor: 

4064 # - Do NOT include %s inside query in a comment - the db api thinks 

4065 # they are actual arguments. 

4066 # - styleKey is currently 'd' (for date) followed by a yyyymmdd 

4067 # date key. Set it to 0000000 or similar to get all records 

4068 # Could also check activeseats here even if only 3 groups eg 2-3/4-6/7+ 

4069 # e.g. could use a multiplier: 

4070 # AND h.seats > %s / 1.25 and hp.seats < %s * 1.25 

4071 # where %s is the number of active players at the current table (and 

4072 # 1.25 would be a config value so user could change it) 

4073 

4074 if db_server == "mysql": 

4075 self.query["get_stats_from_hand_session"] = """ 

4076 SELECT hp.playerId AS player_id, /* playerId and seats must */ 

4077 h.seats AS seats, /* be first and second field */ 

4078 hp.handId AS hand_id, 

4079 hp.seatNo AS seat, 

4080 p.name AS screen_name, 

4081 1 AS n, 

4082 cast(hp2.street0VPIChance as SIGNED) AS vpip_opp, 

4083 cast(hp2.street0VPI as SIGNED) AS vpip, 

4084 cast(hp2.street0AggrChance as SIGNED) AS pfr_opp, 

4085 cast(hp2.street0Aggr as SIGNED) AS pfr, 

4086 cast(hp2.street0CalledRaiseChance as SIGNED) AS CAR_opp_0, 

4087 cast(hp2.street0CalledRaiseDone as SIGNED) AS CAR_0, 

4088 cast(hp2.street0_3BChance as SIGNED) AS TB_opp_0, 

4089 cast(hp2.street0_3BDone as SIGNED) AS TB_0, 

4090 cast(hp2.street0_4BChance as SIGNED) AS FB_opp_0, 

4091 cast(hp2.street0_4BDone as SIGNED) AS FB_0, 

4092 cast(hp2.street0_C4BChance as SIGNED) AS CFB_opp_0, 

4093 cast(hp2.street0_C4BDone as SIGNED) AS CFB_0, 

4094 cast(hp2.street0_FoldTo3BChance as SIGNED) AS F3B_opp_0, 

4095 cast(hp2.street0_FoldTo3BDone as SIGNED) AS F3B_0, 

4096 cast(hp2.street0_FoldTo4BChance as SIGNED) AS F4B_opp_0, 

4097 cast(hp2.street0_FoldTo4BDone as SIGNED) AS F4B_0, 

4098 cast(hp2.street0_SqueezeChance as SIGNED) AS SQZ_opp_0, 

4099 cast(hp2.street0_SqueezeDone as SIGNED) AS SQZ_0, 

4100 cast(hp2.raiseToStealChance as SIGNED) AS RTS_opp, 

4101 cast(hp2.raiseToStealDone as SIGNED) AS RTS, 

4102 cast(hp2.success_Steal as SIGNED) AS SUC_ST, 

4103 cast(hp2.street1Seen as SIGNED) AS saw_f, 

4104 cast(hp2.street1Seen as SIGNED) AS saw_1, 

4105 cast(hp2.street2Seen as SIGNED) AS saw_2, 

4106 cast(hp2.street3Seen as SIGNED) AS saw_3, 

4107 cast(hp2.street4Seen as SIGNED) AS saw_4, 

4108 cast(hp2.sawShowdown as SIGNED) AS sd, 

4109 cast(hp2.street1Aggr as SIGNED) AS aggr_1, 

4110 cast(hp2.street2Aggr as SIGNED) AS aggr_2, 

4111 cast(hp2.street3Aggr as SIGNED) AS aggr_3, 

4112 cast(hp2.street4Aggr as SIGNED) AS aggr_4, 

4113 cast(hp2.otherRaisedStreet1 as SIGNED) AS was_raised_1, 

4114 cast(hp2.otherRaisedStreet2 as SIGNED) AS was_raised_2, 

4115 cast(hp2.otherRaisedStreet3 as SIGNED) AS was_raised_3, 

4116 cast(hp2.otherRaisedStreet4 as SIGNED) AS was_raised_4, 

4117 cast(hp2.foldToOtherRaisedStreet1 as SIGNED) AS f_freq_1, 

4118 cast(hp2.foldToOtherRaisedStreet2 as SIGNED) AS f_freq_2, 

4119 cast(hp2.foldToOtherRaisedStreet3 as SIGNED) AS f_freq_3, 

4120 cast(hp2.foldToOtherRaisedStreet4 as SIGNED) AS f_freq_4, 

4121 cast(hp2.wonWhenSeenStreet1 as SIGNED) AS w_w_s_1, 

4122 cast(hp2.wonAtSD as SIGNED) AS wmsd, 

4123 cast(hp2.stealChance as SIGNED) AS steal_opp, 

4124 cast(hp2.stealDone as SIGNED) AS steal, 

4125 cast(hp2.foldSbToStealChance as SIGNED) AS SBstolen, 

4126 cast(hp2.foldedSbToSteal as SIGNED) AS SBnotDef, 

4127 cast(hp2.foldBbToStealChance as SIGNED) AS BBstolen, 

4128 cast(hp2.foldedBbToSteal as SIGNED) AS BBnotDef, 

4129 cast(hp2.street1CBChance as SIGNED) AS CB_opp_1, 

4130 cast(hp2.street1CBDone as SIGNED) AS CB_1, 

4131 cast(hp2.street2CBChance as SIGNED) AS CB_opp_2, 

4132 cast(hp2.street2CBDone as SIGNED) AS CB_2, 

4133 cast(hp2.street3CBChance as SIGNED) AS CB_opp_3, 

4134 cast(hp2.street3CBDone as SIGNED) AS CB_3, 

4135 cast(hp2.street4CBChance as SIGNED) AS CB_opp_4, 

4136 cast(hp2.street4CBDone as SIGNED) AS CB_4, 

4137 cast(hp2.foldToStreet1CBChance as SIGNED) AS f_cb_opp_1, 

4138 cast(hp2.foldToStreet1CBDone as SIGNED) AS f_cb_1, 

4139 cast(hp2.foldToStreet2CBChance as SIGNED) AS f_cb_opp_2, 

4140 cast(hp2.foldToStreet2CBDone as SIGNED) AS f_cb_2, 

4141 cast(hp2.foldToStreet3CBChance as SIGNED) AS f_cb_opp_3, 

4142 cast(hp2.foldToStreet3CBDone as SIGNED) AS f_cb_3, 

4143 cast(hp2.foldToStreet4CBChance as SIGNED) AS f_cb_opp_4, 

4144 cast(hp2.foldToStreet4CBDone as SIGNED) AS f_cb_4, 

4145 cast(hp2.totalProfit as SIGNED) AS net, 

4146 cast(gt.bigblind as SIGNED) AS bigblind, 

4147 cast(hp2.street1CheckCallRaiseChance as SIGNED) AS ccr_opp_1, 

4148 cast(hp2.street1CheckCallDone as SIGNED) AS cc_1, 

4149 cast(hp2.street1CheckRaiseDone as SIGNED) AS cr_1, 

4150 cast(hp2.street2CheckCallRaiseChance as SIGNED) AS ccr_opp_2, 

4151 cast(hp2.street2CheckCallDone as SIGNED) AS cc_2, 

4152 cast(hp2.street2CheckRaiseDone as SIGNED) AS cr_2, 

4153 cast(hp2.street3CheckCallRaiseChance as SIGNED) AS ccr_opp_3, 

4154 cast(hp2.street3CheckCallDone as SIGNED) AS cc_3, 

4155 cast(hp2.street3CheckRaiseDone as SIGNED) AS cr_3, 

4156 cast(hp2.street4CheckCallRaiseChance as SIGNED) AS ccr_opp_4, 

4157 cast(hp2.street4CheckCallDone as SIGNED) AS cc_4, 

4158 cast(hp2.street4CheckRaiseDone as SIGNED) AS cr_4, 

4159 cast(hp2.street0Calls as SIGNED) AS call_0, 

4160 cast(hp2.street1Calls as SIGNED) AS call_1, 

4161 cast(hp2.street2Calls as SIGNED) AS call_2, 

4162 cast(hp2.street3Calls as SIGNED) AS call_3, 

4163 cast(hp2.street4Calls as SIGNED) AS call_4, 

4164 cast(hp2.street0Bets as SIGNED) AS bet_0, 

4165 cast(hp2.street1Bets as SIGNED) AS bet_1, 

4166 cast(hp2.street2Bets as SIGNED) AS bet_2, 

4167 cast(hp2.street3Bets as SIGNED) AS bet_3, 

4168 cast(hp2.street4Bets as SIGNED) AS bet_4, 

4169 cast(hp2.street0Raises as SIGNED) AS raise_0, 

4170 cast(hp2.street1Raises as SIGNED) AS raise_1, 

4171 cast(hp2.street2Raises as SIGNED) AS raise_2, 

4172 cast(hp2.street3Raises as SIGNED) AS raise_3, 

4173 cast(hp2.street4Raises as SIGNED) AS raise_4 

4174 FROM 

4175 Hands h 

4176 INNER JOIN Hands h2 ON (h2.id >= %s AND h2.tableName = h.tableName) 

4177 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */ 

4178 INNER JOIN HandsPlayers hp2 ON (hp2.playerId+0 = hp.playerId+0 AND (hp2.handId = h2.id+0)) /* other hands by these players */ 

4179 INNER JOIN Players p ON (p.id = hp2.PlayerId+0) 

4180 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId) 

4181 WHERE hp.handId = %s 

4182 /* check activeseats once this data returned (don't want to do that here as it might 

4183 assume a session ended just because the number of seats dipped for a few hands) 

4184 */ 

4185 AND ( /* 2 separate parts for hero and opponents */ 

4186 ( hp2.playerId != %s 

4187 AND h2.seats between %s and %s 

4188 ) 

4189 OR 

4190 ( hp2.playerId = %s 

4191 AND h2.seats between %s and %s 

4192 ) 

4193 ) 

4194 ORDER BY h.startTime desc, hp2.PlayerId 

4195 /* order rows by handstart descending so that we can stop reading rows when 

4196 there's a gap over X minutes between hands (ie. when we get back to start of 

4197 the session */ 

4198 """ 

4199 elif db_server == "postgresql": 

4200 self.query["get_stats_from_hand_session"] = """ 

4201 SELECT hp.playerId AS player_id, 

4202 hp.handId AS hand_id, 

4203 hp.seatNo AS seat, 

4204 p.name AS screen_name, 

4205 h.seats AS seats, 

4206 1 AS n, 

4207 cast(hp2.street0VPIChance as <signed>integer) AS vpip_opp, 

4208 cast(hp2.street0VPI as <signed>integer) AS vpip, 

4209 cast(hp2.street0AggrChance as <signed>integer) AS pfr_opp, 

4210 cast(hp2.street0Aggr as <signed>integer) AS pfr, 

4211 cast(hp2.street0CalledRaiseChance as <signed>integer) AS CAR_opp_0, 

4212 cast(hp2.street0CalledRaiseDone as <signed>integer) AS CAR_0, 

4213 cast(hp2.street0_3BChance as <signed>integer) AS TB_opp_0, 

4214 cast(hp2.street0_3BDone as <signed>integer) AS TB_0, 

4215 cast(hp2.street0_4BChance as <signed>integer) AS FB_opp_0, 

4216 cast(hp2.street0_4BDone as <signed>integer) AS FB_0, 

4217 cast(hp2.street0_C4BChance as <signed>integer) AS CFB_opp_0, 

4218 cast(hp2.street0_C4BDone as <signed>integer) AS CFB_0, 

4219 cast(hp2.street0_FoldTo3BChance as <signed>integer) AS F3B_opp_0, 

4220 cast(hp2.street0_FoldTo3BDone as <signed>integer) AS F3B_0, 

4221 cast(hp2.street0_FoldTo4BChance as <signed>integer) AS F4B_opp_0, 

4222 cast(hp2.street0_FoldTo4BDone as <signed>integer) AS F4B_0, 

4223 cast(hp2.street0_SqueezeChance as <signed>integer) AS SQZ_opp_0, 

4224 cast(hp2.street0_SqueezeDone as <signed>integer) AS SQZ_0, 

4225 cast(hp2.raiseToStealChance as <signed>integer) AS RTS_opp, 

4226 cast(hp2.raiseToStealDone as <signed>integer) AS RTS, 

4227 cast(hp2.success_Steal as <signed>integer) AS SUC_ST, 

4228 cast(hp2.street1Seen as <signed>integer) AS saw_f, 

4229 cast(hp2.street1Seen as <signed>integer) AS saw_1, 

4230 cast(hp2.street2Seen as <signed>integer) AS saw_2, 

4231 cast(hp2.street3Seen as <signed>integer) AS saw_3, 

4232 cast(hp2.street4Seen as <signed>integer) AS saw_4, 

4233 cast(hp2.sawShowdown as <signed>integer) AS sd, 

4234 cast(hp2.street1Aggr as <signed>integer) AS aggr_1, 

4235 cast(hp2.street2Aggr as <signed>integer) AS aggr_2, 

4236 cast(hp2.street3Aggr as <signed>integer) AS aggr_3, 

4237 cast(hp2.street4Aggr as <signed>integer) AS aggr_4, 

4238 cast(hp2.otherRaisedStreet1 as <signed>integer) AS was_raised_1, 

4239 cast(hp2.otherRaisedStreet2 as <signed>integer) AS was_raised_2, 

4240 cast(hp2.otherRaisedStreet3 as <signed>integer) AS was_raised_3, 

4241 cast(hp2.otherRaisedStreet4 as <signed>integer) AS was_raised_4, 

4242 cast(hp2.foldToOtherRaisedStreet1 as <signed>integer) AS f_freq_1, 

4243 cast(hp2.foldToOtherRaisedStreet2 as <signed>integer) AS f_freq_2, 

4244 cast(hp2.foldToOtherRaisedStreet3 as <signed>integer) AS f_freq_3, 

4245 cast(hp2.foldToOtherRaisedStreet4 as <signed>integer) AS f_freq_4, 

4246 cast(hp2.wonWhenSeenStreet1 as <signed>integer) AS w_w_s_1, 

4247 cast(hp2.wonAtSD as <signed>integer) AS wmsd, 

4248 cast(hp2.stealChance as <signed>integer) AS steal_opp, 

4249 cast(hp2.stealDone as <signed>integer) AS steal, 

4250 cast(hp2.foldSbToStealChance as <signed>integer) AS SBstolen, 

4251 cast(hp2.foldedSbToSteal as <signed>integer) AS SBnotDef, 

4252 cast(hp2.foldBbToStealChance as <signed>integer) AS BBstolen, 

4253 cast(hp2.foldedBbToSteal as <signed>integer) AS BBnotDef, 

4254 cast(hp2.street1CBChance as <signed>integer) AS CB_opp_1, 

4255 cast(hp2.street1CBDone as <signed>integer) AS CB_1, 

4256 cast(hp2.street2CBChance as <signed>integer) AS CB_opp_2, 

4257 cast(hp2.street2CBDone as <signed>integer) AS CB_2, 

4258 cast(hp2.street3CBChance as <signed>integer) AS CB_opp_3, 

4259 cast(hp2.street3CBDone as <signed>integer) AS CB_3, 

4260 cast(hp2.street4CBChance as <signed>integer) AS CB_opp_4, 

4261 cast(hp2.street4CBDone as <signed>integer) AS CB_4, 

4262 cast(hp2.foldToStreet1CBChance as <signed>integer) AS f_cb_opp_1, 

4263 cast(hp2.foldToStreet1CBDone as <signed>integer) AS f_cb_1, 

4264 cast(hp2.foldToStreet2CBChance as <signed>integer) AS f_cb_opp_2, 

4265 cast(hp2.foldToStreet2CBDone as <signed>integer) AS f_cb_2, 

4266 cast(hp2.foldToStreet3CBChance as <signed>integer) AS f_cb_opp_3, 

4267 cast(hp2.foldToStreet3CBDone as <signed>integer) AS f_cb_3, 

4268 cast(hp2.foldToStreet4CBChance as <signed>integer) AS f_cb_opp_4, 

4269 cast(hp2.foldToStreet4CBDone as <signed>integer) AS f_cb_4, 

4270 cast(hp2.totalProfit as <signed>bigint) AS net, 

4271 cast(gt.bigblind as <signed>bigint) AS bigblind, 

4272 cast(hp2.street1CheckCallRaiseChance as <signed>integer) AS ccr_opp_1, 

4273 cast(hp2.street1CheckCallDone as <signed>integer) AS cc_1, 

4274 cast(hp2.street1CheckRaiseDone as <signed>integer) AS cr_1, 

4275 cast(hp2.street2CheckCallRaiseChance as <signed>integer) AS ccr_opp_2, 

4276 cast(hp2.street2CheckCallDone as <signed>integer) AS cc_2, 

4277 cast(hp2.street2CheckRaiseDone as <signed>integer) AS cr_2, 

4278 cast(hp2.street3CheckCallRaiseChance as <signed>integer) AS ccr_opp_3, 

4279 cast(hp2.street3CheckCallDone as <signed>integer) AS cc_3, 

4280 cast(hp2.street3CheckRaiseDone as <signed>integer) AS cr_3, 

4281 cast(hp2.street4CheckCallRaiseChance as <signed>integer) AS ccr_opp_4, 

4282 cast(hp2.street4CheckCallDone as <signed>integer) AS cc_4, 

4283 cast(hp2.street4CheckRaiseDone as <signed>integer) AS cr_4, 

4284 cast(hp2.street0Calls as <signed>integer) AS call_0, 

4285 cast(hp2.street1Calls as <signed>integer) AS call_1, 

4286 cast(hp2.street2Calls as <signed>integer) AS call_2, 

4287 cast(hp2.street3Calls as <signed>integer) AS call_3, 

4288 cast(hp2.street4Calls as <signed>integer) AS call_4, 

4289 cast(hp2.street0Bets as <signed>integer) AS bet_0, 

4290 cast(hp2.street1Bets as <signed>integer) AS bet_1, 

4291 cast(hp2.street2Bets as <signed>integer) AS bet_2, 

4292 cast(hp2.street3Bets as <signed>integer) AS bet_3, 

4293 cast(hp2.street4Bets as <signed>integer) AS bet_4, 

4294 cast(hp2.street0Raises as <signed>integer) AS raise_0, 

4295 cast(hp2.street1Raises as <signed>integer) AS raise_1, 

4296 cast(hp2.street2Raises as <signed>integer) AS raise_2, 

4297 cast(hp2.street3Raises as <signed>integer) AS raise_3, 

4298 cast(hp2.street4Raises as <signed>integer) AS raise_4 

4299 FROM Hands h /* this hand */ 

4300 INNER JOIN Hands h2 ON ( h2.id >= %s /* other hands */ 

4301 AND h2.tableName = h.tableName) 

4302 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */ 

4303 INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0 

4304 AND hp2.handId = h2.id) /* other hands by these players */ 

4305 INNER JOIN Players p ON (p.id = hp2.PlayerId+0) 

4306 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId) 

4307 WHERE h.id = %s 

4308 /* check activeseats once this data returned (don't want to do that here as it might 

4309 assume a session ended just because the number of seats dipped for a few hands) 

4310 */ 

4311 AND ( /* 2 separate parts for hero and opponents */ 

4312 ( hp2.playerId != %s 

4313 AND h2.seats between %s and %s 

4314 ) 

4315 OR 

4316 ( hp2.playerId = %s 

4317 AND h2.seats between %s and %s 

4318 ) 

4319 ) 

4320 ORDER BY h.startTime desc, hp2.PlayerId 

4321 /* order rows by handstart descending so that we can stop reading rows when 

4322 there's a gap over X minutes between hands (ie. when we get back to start of 

4323 the session */ 

4324 """ 

4325 elif db_server == "sqlite": 

4326 self.query["get_stats_from_hand_session"] = """ 

4327 SELECT hp.playerId AS player_id, 

4328 hp.handId AS hand_id, 

4329 hp.seatNo AS seat, 

4330 p.name AS screen_name, 

4331 h.seats AS seats, 

4332 1 AS n, 

4333 cast(hp2.street0VPIChance as <signed>integer) AS vpip_opp, 

4334 cast(hp2.street0VPI as <signed>integer) AS vpip, 

4335 cast(hp2.street0AggrChance as <signed>integer) AS pfr_opp, 

4336 cast(hp2.street0Aggr as <signed>integer) AS pfr, 

4337 cast(hp2.street0CalledRaiseChance as <signed>integer) AS CAR_opp_0, 

4338 cast(hp2.street0CalledRaiseDone as <signed>integer) AS CAR_0, 

4339 cast(hp2.street0_3BChance as <signed>integer) AS TB_opp_0, 

4340 cast(hp2.street0_3BDone as <signed>integer) AS TB_0, 

4341 cast(hp2.street0_4BChance as <signed>integer) AS FB_opp_0, 

4342 cast(hp2.street0_4BDone as <signed>integer) AS FB_0, 

4343 cast(hp2.street0_C4BChance as <signed>integer) AS CFB_opp_0, 

4344 cast(hp2.street0_C4BDone as <signed>integer) AS CFB_0, 

4345 cast(hp2.street0_FoldTo3BChance as <signed>integer) AS F3B_opp_0, 

4346 cast(hp2.street0_FoldTo3BDone as <signed>integer) AS F3B_0, 

4347 cast(hp2.street0_FoldTo4BChance as <signed>integer) AS F4B_opp_0, 

4348 cast(hp2.street0_FoldTo4BDone as <signed>integer) AS F4B_0, 

4349 cast(hp2.street0_SqueezeChance as <signed>integer) AS SQZ_opp_0, 

4350 cast(hp2.street0_SqueezeDone as <signed>integer) AS SQZ_0, 

4351 cast(hp2.raiseToStealChance as <signed>integer) AS RTS_opp, 

4352 cast(hp2.raiseToStealDone as <signed>integer) AS RTS, 

4353 cast(hp2.success_Steal as <signed>integer) AS SUC_ST, 

4354 cast(hp2.street1Seen as <signed>integer) AS saw_f, 

4355 cast(hp2.street1Seen as <signed>integer) AS saw_1, 

4356 cast(hp2.street2Seen as <signed>integer) AS saw_2, 

4357 cast(hp2.street3Seen as <signed>integer) AS saw_3, 

4358 cast(hp2.street4Seen as <signed>integer) AS saw_4, 

4359 cast(hp2.sawShowdown as <signed>integer) AS sd, 

4360 cast(hp2.street1Aggr as <signed>integer) AS aggr_1, 

4361 cast(hp2.street2Aggr as <signed>integer) AS aggr_2, 

4362 cast(hp2.street3Aggr as <signed>integer) AS aggr_3, 

4363 cast(hp2.street4Aggr as <signed>integer) AS aggr_4, 

4364 cast(hp2.otherRaisedStreet1 as <signed>integer) AS was_raised_1, 

4365 cast(hp2.otherRaisedStreet2 as <signed>integer) AS was_raised_2, 

4366 cast(hp2.otherRaisedStreet3 as <signed>integer) AS was_raised_3, 

4367 cast(hp2.otherRaisedStreet4 as <signed>integer) AS was_raised_4, 

4368 cast(hp2.foldToOtherRaisedStreet1 as <signed>integer) AS f_freq_1, 

4369 cast(hp2.foldToOtherRaisedStreet2 as <signed>integer) AS f_freq_2, 

4370 cast(hp2.foldToOtherRaisedStreet3 as <signed>integer) AS f_freq_3, 

4371 cast(hp2.foldToOtherRaisedStreet4 as <signed>integer) AS f_freq_4, 

4372 cast(hp2.wonWhenSeenStreet1 as <signed>integer) AS w_w_s_1, 

4373 cast(hp2.wonAtSD as <signed>integer) AS wmsd, 

4374 cast(hp2.stealChance as <signed>integer) AS steal_opp, 

4375 cast(hp2.stealDone as <signed>integer) AS steal, 

4376 cast(hp2.foldSbToStealChance as <signed>integer) AS SBstolen, 

4377 cast(hp2.foldedSbToSteal as <signed>integer) AS SBnotDef, 

4378 cast(hp2.foldBbToStealChance as <signed>integer) AS BBstolen, 

4379 cast(hp2.foldedBbToSteal as <signed>integer) AS BBnotDef, 

4380 cast(hp2.street1CBChance as <signed>integer) AS CB_opp_1, 

4381 cast(hp2.street1CBDone as <signed>integer) AS CB_1, 

4382 cast(hp2.street2CBChance as <signed>integer) AS CB_opp_2, 

4383 cast(hp2.street2CBDone as <signed>integer) AS CB_2, 

4384 cast(hp2.street3CBChance as <signed>integer) AS CB_opp_3, 

4385 cast(hp2.street3CBDone as <signed>integer) AS CB_3, 

4386 cast(hp2.street4CBChance as <signed>integer) AS CB_opp_4, 

4387 cast(hp2.street4CBDone as <signed>integer) AS CB_4, 

4388 cast(hp2.foldToStreet1CBChance as <signed>integer) AS f_cb_opp_1, 

4389 cast(hp2.foldToStreet1CBDone as <signed>integer) AS f_cb_1, 

4390 cast(hp2.foldToStreet2CBChance as <signed>integer) AS f_cb_opp_2, 

4391 cast(hp2.foldToStreet2CBDone as <signed>integer) AS f_cb_2, 

4392 cast(hp2.foldToStreet3CBChance as <signed>integer) AS f_cb_opp_3, 

4393 cast(hp2.foldToStreet3CBDone as <signed>integer) AS f_cb_3, 

4394 cast(hp2.foldToStreet4CBChance as <signed>integer) AS f_cb_opp_4, 

4395 cast(hp2.foldToStreet4CBDone as <signed>integer) AS f_cb_4, 

4396 cast(hp2.totalProfit as <signed>integer) AS net, 

4397 cast(gt.bigblind as <signed>integer) AS bigblind, 

4398 cast(hp2.street1CheckCallRaiseChance as <signed>integer) AS ccr_opp_1, 

4399 cast(hp2.street1CheckCallDone as <signed>integer) AS cc_1, 

4400 cast(hp2.street1CheckRaiseDone as <signed>integer) AS cr_1, 

4401 cast(hp2.street2CheckCallRaiseChance as <signed>integer) AS ccr_opp_2, 

4402 cast(hp2.street2CheckCallDone as <signed>integer) AS cc_2, 

4403 cast(hp2.street2CheckRaiseDone as <signed>integer) AS cr_2, 

4404 cast(hp2.street3CheckCallRaiseChance as <signed>integer) AS ccr_opp_3, 

4405 cast(hp2.street3CheckCallDone as <signed>integer) AS cc_3, 

4406 cast(hp2.street3CheckRaiseDone as <signed>integer) AS cr_3, 

4407 cast(hp2.street4CheckCallRaiseChance as <signed>integer) AS ccr_opp_4, 

4408 cast(hp2.street4CheckCallDone as <signed>integer) AS cc_4, 

4409 cast(hp2.street4CheckRaiseDone as <signed>integer) AS cr_4, 

4410 cast(hp2.street0Calls as <signed>integer) AS call_0, 

4411 cast(hp2.street1Calls as <signed>integer) AS call_1, 

4412 cast(hp2.street2Calls as <signed>integer) AS call_2, 

4413 cast(hp2.street3Calls as <signed>integer) AS call_3, 

4414 cast(hp2.street4Calls as <signed>integer) AS call_4, 

4415 cast(hp2.street0Bets as <signed>integer) AS bet_0, 

4416 cast(hp2.street1Bets as <signed>integer) AS bet_1, 

4417 cast(hp2.street2Bets as <signed>integer) AS bet_2, 

4418 cast(hp2.street3Bets as <signed>integer) AS bet_3, 

4419 cast(hp2.street4Bets as <signed>integer) AS bet_4, 

4420 cast(hp2.street0Raises as <signed>integer) AS raise_0, 

4421 cast(hp2.street1Raises as <signed>integer) AS raise_1, 

4422 cast(hp2.street2Raises as <signed>integer) AS raise_2, 

4423 cast(hp2.street3Raises as <signed>integer) AS raise_3, 

4424 cast(hp2.street4Raises as <signed>integer) AS raise_4 

4425 FROM Hands h /* this hand */ 

4426 INNER JOIN Hands h2 ON ( h2.id >= %s /* other hands */ 

4427 AND h2.tableName = h.tableName) 

4428 INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */ 

4429 INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0 

4430 AND hp2.handId = h2.id) /* other hands by these players */ 

4431 INNER JOIN Players p ON (p.id = hp2.PlayerId+0) 

4432 INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId) 

4433 WHERE h.id = %s 

4434 /* check activeseats once this data returned (don't want to do that here as it might 

4435 assume a session ended just because the number of seats dipped for a few hands) 

4436 */ 

4437 AND ( /* 2 separate parts for hero and opponents */ 

4438 ( hp2.playerId != %s 

4439 AND h2.seats between %s and %s 

4440 ) 

4441 OR 

4442 ( hp2.playerId = %s 

4443 AND h2.seats between %s and %s 

4444 ) 

4445 ) 

4446 ORDER BY h.startTime desc, hp2.PlayerId 

4447 /* order rows by handstart descending so that we can stop reading rows when 

4448 there's a gap over X minutes between hands (ie. when we get back to start of 

4449 the session */ 

4450 """ 

4451 

4452 self.query["get_players_from_hand"] = """ 

4453 SELECT HandsPlayers.playerId, seatNo, name 

4454 FROM HandsPlayers INNER JOIN Players ON (HandsPlayers.playerId = Players.id) 

4455 WHERE handId = %s 

4456 """ 

4457 # WHERE handId = %s AND Players.id LIKE %s 

4458 

4459 self.query["get_winners_from_hand"] = """ 

4460 SELECT name, winnings 

4461 FROM HandsPlayers, Players 

4462 WHERE winnings > 0 

4463 AND Players.id = HandsPlayers.playerId 

4464 AND handId = %s; 

4465 """ 

4466 

4467 self.query["get_table_name"] = """ 

4468 SELECT h.tableName, gt.maxSeats, gt.category, gt.type, gt.fast, s.id, s.name 

4469 , count(1) as numseats 

4470 FROM Hands h, Gametypes gt, Sites s, HandsPlayers hp 

4471 WHERE h.id = %s 

4472 AND gt.id = h.gametypeId 

4473 AND s.id = gt.siteID 

4474 AND hp.handId = h.id 

4475 GROUP BY h.tableName, gt.maxSeats, gt.category, gt.type, gt.fast, s.id, s.name 

4476 """ 

4477 

4478 self.query["get_actual_seat"] = """ 

4479 select seatNo 

4480 from HandsPlayers 

4481 where HandsPlayers.handId = %s 

4482 and HandsPlayers.playerId = (select Players.id from Players 

4483 where Players.name = %s) 

4484 """ 

4485 

4486 self.query["get_cards"] = """ 

4487/* 

4488 changed to activate mucked card display in draw games 

4489 in draw games, card6->card20 contain 3 sets of 5 cards at each draw 

4490 

4491 CASE code searches from the highest card number (latest draw) and when 

4492 it finds a non-zero card, it returns that set of data 

4493*/ 

4494 SELECT 

4495 seatNo AS seat_number, 

4496 CASE Gametypes.base 

4497 when 'draw' then COALESCE(NULLIF(card16,0), NULLIF(card11,0), NULLIF(card6,0), card1) 

4498 else card1 

4499 end card1, 

4500 CASE Gametypes.base 

4501 when 'draw' then COALESCE(NULLIF(card17,0), NULLIF(card12,0), NULLIF(card7,0), card2) 

4502 else card2 

4503 end card2, 

4504 CASE Gametypes.base 

4505 when 'draw' then COALESCE(NULLIF(card18,0), NULLIF(card13,0), NULLIF(card8,0), card3) 

4506 else card3 

4507 end card3, 

4508 CASE Gametypes.base 

4509 when 'draw' then COALESCE(NULLIF(card19,0), NULLIF(card14,0), NULLIF(card9,0), card4) 

4510 else card4 

4511 end card4, 

4512 CASE Gametypes.base 

4513 when 'draw' then COALESCE(NULLIF(card20,0), NULLIF(card15,0), NULLIF(card10,0), card5) 

4514 else card5 

4515 end card5, 

4516 CASE Gametypes.base 

4517 when 'draw' then 0 

4518 else card6 

4519 end card6, 

4520 CASE Gametypes.base 

4521 when 'draw' then 0 

4522 else card7 

4523 end card7 

4524 

4525 FROM HandsPlayers, Hands, Gametypes 

4526 WHERE handID = %s 

4527 AND HandsPlayers.handId=Hands.id 

4528 AND Hands.gametypeId = Gametypes.id 

4529 ORDER BY seatNo 

4530 """ 

4531 

4532 self.query["get_common_cards"] = """ 

4533 select 

4534 boardcard1, 

4535 boardcard2, 

4536 boardcard3, 

4537 boardcard4, 

4538 boardcard5 

4539 from Hands 

4540 where Id = %s 

4541 """ 

4542 

4543 if db_server == "mysql": 

4544 self.query["get_hand_1day_ago"] = """ 

4545 select coalesce(max(id),0) 

4546 from Hands 

4547 where startTime < date_sub(utc_timestamp(), interval '1' day)""" 

4548 elif db_server == "postgresql": 

4549 self.query["get_hand_1day_ago"] = """ 

4550 select coalesce(max(id),0) 

4551 from Hands 

4552 where startTime < now() at time zone 'UTC' - interval '1 day'""" 

4553 elif db_server == "sqlite": 

4554 self.query["get_hand_1day_ago"] = """ 

4555 select coalesce(max(id),0) 

4556 from Hands 

4557 where startTime < datetime(strftime('%J', 'now') - 1)""" 

4558 

4559 # not used yet ... 

4560 # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id 

4561 if db_server == "mysql": 

4562 self.query["get_date_nhands_ago"] = """ 

4563 select concat( 'd', date_format(max(h.startTime), '%Y%m%d') ) 

4564 from (select hp.playerId 

4565 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx 

4566 from HandsPlayers hp 

4567 where hp.playerId = %s 

4568 group by hp.playerId) hp2 

4569 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx 

4570 and hp3.playerId = hp2.playerId) 

4571 inner join Hands h on (h.id = hp3.handId) 

4572 """ 

4573 elif db_server == "postgresql": 

4574 self.query["get_date_nhands_ago"] = """ 

4575 select 'd' || to_char(max(h3.startTime), 'YYMMDD') 

4576 from (select hp.playerId 

4577 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx 

4578 from HandsPlayers hp 

4579 where hp.playerId = %s 

4580 group by hp.playerId) hp2 

4581 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx 

4582 and hp3.playerId = hp2.playerId) 

4583 inner join Hands h on (h.id = hp3.handId) 

4584 """ 

4585 elif db_server == "sqlite": # untested guess at query: 

4586 self.query["get_date_nhands_ago"] = """ 

4587 select 'd' || strftime(max(h3.startTime), 'YYMMDD') 

4588 from (select hp.playerId 

4589 ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx 

4590 from HandsPlayers hp 

4591 where hp.playerId = %s 

4592 group by hp.playerId) hp2 

4593 inner join HandsPlayers hp3 on ( hp3.handId <= hp2.maxminusx 

4594 and hp3.playerId = hp2.playerId) 

4595 inner join Hands h on (h.id = hp3.handId) 

4596 """ 

4597 

4598 # Used in *Filters: 

4599 # self.query['getLimits'] = already defined further up 

4600 self.query["getLimits2"] = """SELECT DISTINCT type, limitType, bigBlind  

4601 from Gametypes 

4602 ORDER by type, limitType DESC, bigBlind DESC""" 

4603 self.query["getLimits3"] = """select DISTINCT type 

4604 , gt.limitType 

4605 , case type 

4606 when 'ring' then bigBlind  

4607- else buyin 

4608- end as bb_or_buyin 

4609 from Gametypes gt 

4610 cross join TourneyTypes tt 

4611 order by type, gt.limitType DESC, bb_or_buyin DESC""" 

4612 # self.query['getCashLimits'] = """select DISTINCT type 

4613 # , limitType 

4614 # , bigBlind as bb_or_buyin 

4615 # from Gametypes gt 

4616 # WHERE type = 'ring' 

4617 # order by type, limitType DESC, bb_or_buyin DESC""" 

4618 

4619 self.query["getCashLimits"] = """select DISTINCT type 

4620 , limitType 

4621 , bigBlind as bb_or_buyin 

4622 from Gametypes gt 

4623 WHERE type = 'ring' 

4624 order by type, limitType DESC, bb_or_buyin DESC""" 

4625 

4626 self.query["getPositions"] = """select distinct position 

4627 from HandsPlayers gt 

4628 order by position""" 

4629 

4630 # FIXME: Some stats not added to DetailedStats (miss raise to steal) 

4631 if db_server == "mysql": 

4632 self.query["playerDetailedStats"] = """ 

4633 select <hgametypeId> AS hgametypeid 

4634 ,<playerName> AS pname 

4635 ,gt.base 

4636 ,gt.category 

4637 ,upper(gt.limitType) AS limittype 

4638 ,s.name 

4639 ,min(gt.bigBlind) AS minbigblind 

4640 ,max(gt.bigBlind) AS maxbigblind 

4641 ,gt.ante AS ante 

4642 ,gt.currency AS currency 

4643 /*,<hcgametypeId> AS gtid*/ 

4644 ,<position> AS plposition 

4645 ,gt.fast AS fast 

4646 ,count(1) AS n 

4647 ,case when sum(cast(hp.street0VPIChance as SIGNED)) = 0 then -999 

4648 else 100.0*sum(cast(hp.street0VPI as SIGNED))/sum(cast(hp.street0VPIChance as SIGNED)) 

4649 end AS vpip 

4650 ,case when sum(cast(hp.street0AggrChance as SIGNED)) = 0 then -999 

4651 else 100.0*sum(cast(hp.street0Aggr as SIGNED))/sum(cast(hp.street0AggrChance as SIGNED)) 

4652 end AS pfr 

4653 ,case when sum(cast(hp.street0CalledRaiseChance as SIGNED)) = 0 then -999 

4654 else 100.0*sum(cast(hp.street0CalledRaiseDone as SIGNED))/sum(cast(hp.street0CalledRaiseChance as SIGNED)) 

4655 end AS car0 

4656 ,case when sum(cast(hp.street0_3Bchance as SIGNED)) = 0 then -999 

4657 else 100.0*sum(cast(hp.street0_3Bdone as SIGNED))/sum(cast(hp.street0_3Bchance as SIGNED)) 

4658 end AS pf3 

4659 ,case when sum(cast(hp.street0_4Bchance as SIGNED)) = 0 then -999 

4660 else 100.0*sum(cast(hp.street0_4Bdone as SIGNED))/sum(cast(hp.street0_4Bchance as SIGNED)) 

4661 end AS pf4 

4662 ,case when sum(cast(hp.street0_FoldTo3Bchance as SIGNED)) = 0 then -999 

4663 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as SIGNED))/sum(cast(hp.street0_FoldTo3Bchance as SIGNED)) 

4664 end AS pff3 

4665 ,case when sum(cast(hp.street0_FoldTo4Bchance as SIGNED)) = 0 then -999 

4666 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as SIGNED))/sum(cast(hp.street0_FoldTo4Bchance as SIGNED)) 

4667 end AS pff4 

4668 

4669 ,case when sum(cast(hp.raiseFirstInChance as SIGNED)) = 0 then -999 

4670 else 100.0 * sum(cast(hp.raisedFirstIn as SIGNED)) /  

4671 sum(cast(hp.raiseFirstInChance as SIGNED)) 

4672 end AS rfi 

4673 ,case when sum(cast(hp.stealChance as SIGNED)) = 0 then -999 

4674 else 100.0 * sum(cast(hp.stealDone as SIGNED)) /  

4675 sum(cast(hp.stealChance as SIGNED)) 

4676 end AS steals 

4677 ,case when sum(cast(hp.stealDone as SIGNED)) = 0 then -999 

4678 else 100.0 * sum(cast(hp.success_Steal as SIGNED)) /  

4679 sum(cast(hp.stealDone as SIGNED)) 

4680 end AS suc_steal 

4681 ,100.0*sum(cast(hp.street1Seen as SIGNED))/count(1) AS saw_f 

4682 ,100.0*sum(cast(hp.sawShowdown as SIGNED))/count(1) AS sawsd 

4683 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999 

4684 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as SIGNED))/sum(cast(hp.street1Seen as SIGNED)) 

4685 end AS wmsf 

4686 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999 

4687 else 100.0*sum(cast(hp.sawShowdown as SIGNED))/sum(cast(hp.street1Seen as SIGNED)) 

4688 end AS wtsdwsf 

4689 ,case when sum(cast(hp.sawShowdown as SIGNED)) = 0 then -999 

4690 else 100.0*sum(cast(hp.wonAtSD as SIGNED))/sum(cast(hp.sawShowdown as SIGNED)) 

4691 end AS wmsd 

4692 ,case when sum(cast(hp.street1Seen as SIGNED)) = 0 then -999 

4693 else 100.0*sum(cast(hp.street1Aggr as SIGNED))/sum(cast(hp.street1Seen as SIGNED)) 

4694 end AS flafq 

4695 ,case when sum(cast(hp.street2Seen as SIGNED)) = 0 then -999 

4696 else 100.0*sum(cast(hp.street2Aggr as SIGNED))/sum(cast(hp.street2Seen as SIGNED)) 

4697 end AS tuafq 

4698 ,case when sum(cast(hp.street3Seen as SIGNED)) = 0 then -999 

4699 else 100.0*sum(cast(hp.street3Aggr as SIGNED))/sum(cast(hp.street3Seen as SIGNED)) 

4700 end AS rvafq 

4701 ,case when sum(cast(hp.street1Seen as SIGNED))+sum(cast(hp.street2Seen as SIGNED))+sum(cast(hp.street3Seen as SIGNED)) = 0 then -999 

4702 else 100.0*(sum(cast(hp.street1Aggr as SIGNED))+sum(cast(hp.street2Aggr as SIGNED))+sum(cast(hp.street3Aggr as SIGNED))) 

4703 /(sum(cast(hp.street1Seen as SIGNED))+sum(cast(hp.street2Seen as SIGNED))+sum(cast(hp.street3Seen as SIGNED))) 

4704 end AS pofafq 

4705 ,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 

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

4707 /(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))) 

4708 end AS aggfac 

4709 ,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)))  

4710 / ((sum(cast(hp.foldToOtherRaisedStreet1 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet2 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet3 as SIGNED))+ sum(cast(hp.foldToOtherRaisedStreet4 as SIGNED))) + 

4711 (sum(cast(hp.street1Calls as SIGNED))+ sum(cast(hp.street2Calls as SIGNED))+ sum(cast(hp.street3Calls as SIGNED))+ sum(cast(hp.street4Calls as SIGNED))) + 

4712 (sum(cast(hp.street1Aggr as SIGNED)) + sum(cast(hp.street2Aggr as SIGNED)) + sum(cast(hp.street3Aggr as SIGNED)) + sum(cast(hp.street4Aggr as SIGNED))) ) 

4713 AS aggfrq 

4714 ,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)))  

4715 / (sum(cast(hp.street1CBChance as SIGNED))+ sum(cast(hp.street2CBChance as SIGNED))+ sum(cast(hp.street3CBChance as SIGNED))+ sum(cast(hp.street4CBChance as SIGNED)))  

4716 AS conbet 

4717 ,sum(hp.totalProfit)/100.0 AS net 

4718 ,sum(hp.rake)/100.0 AS rake 

4719 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100 

4720 ,avg(hp.totalProfit)/100.0 AS profitperhand 

4721 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr 

4722 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr 

4723 ,avg(h.seats+0.0) AS avgseats 

4724 ,variance(hp.totalProfit/100.0) AS variance 

4725 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev 

4726 from HandsPlayers hp 

4727 inner join Hands h on (h.id = hp.handId) 

4728 inner join Gametypes gt on (gt.Id = h.gametypeId) 

4729 inner join Sites s on (s.Id = gt.siteId) 

4730 inner join Players p on (p.Id = hp.playerId) 

4731 where hp.playerId in <player_test> 

4732 <game_test> 

4733 <site_test> 

4734 <currency_test> 

4735 /*and hp.tourneysPlayersId IS NULL*/ 

4736 and h.seats <seats_test> 

4737 <flagtest> 

4738 <cardstest> 

4739 <gtbigBlind_test> 

4740 and date_format(h.startTime, '%Y-%m-%d %T') <datestest> 

4741 group by hgametypeId 

4742 ,pname 

4743 ,gt.base 

4744 ,gt.category 

4745 <groupbyseats> 

4746 ,plposition 

4747 ,upper(gt.limitType) 

4748 ,gt.fast 

4749 ,s.name 

4750 having 1 = 1 <havingclause> 

4751 order by pname 

4752 ,gt.base 

4753 ,gt.category 

4754 <orderbyseats> 

4755 ,case <position> when 'B' then 'B' 

4756 when 'S' then 'S' 

4757 else concat('Z', <position>) 

4758 end 

4759 <orderbyhgametypeId> 

4760 ,upper(gt.limitType) desc 

4761 ,maxbigblind desc 

4762 ,gt.fast 

4763 ,s.name 

4764 """ 

4765 elif db_server == "postgresql": 

4766 self.query["playerDetailedStats"] = """ 

4767 select <hgametypeId> AS hgametypeid 

4768 ,<playerName> AS pname 

4769 ,gt.base 

4770 ,gt.category 

4771 ,upper(gt.limitType) AS limittype 

4772 ,s.name 

4773 ,min(gt.bigBlind) AS minbigblind 

4774 ,max(gt.bigBlind) AS maxbigblind 

4775 ,gt.ante AS ante 

4776 ,gt.currency AS currency 

4777 /*,<hcgametypeId> AS gtid*/ 

4778 ,<position> AS plposition 

4779 ,gt.fast AS fast 

4780 ,count(1) AS n 

4781 ,case when sum(cast(hp.street0VPIChance as <signed>integer)) = 0 then -999 

4782 else 100.0*sum(cast(hp.street0VPI as <signed>integer))/sum(cast(hp.street0VPIChance as <signed>integer)) 

4783 end AS vpip 

4784 ,case when sum(cast(hp.street0AggrChance as <signed>integer)) = 0 then -999 

4785 else 100.0*sum(cast(hp.street0Aggr as <signed>integer))/sum(cast(hp.street0AggrChance as <signed>integer)) 

4786 end AS pfr 

4787 ,case when sum(cast(hp.street0CalledRaiseChance as <signed>integer)) = 0 then -999 

4788 else 100.0*sum(cast(hp.street0CalledRaiseDone as <signed>integer))/sum(cast(hp.street0CalledRaiseChance as <signed>integer)) 

4789 end AS car0 

4790 ,case when sum(cast(hp.street0_3Bchance as <signed>integer)) = 0 then -999 

4791 else 100.0*sum(cast(hp.street0_3Bdone as <signed>integer))/sum(cast(hp.street0_3Bchance as <signed>integer)) 

4792 end AS pf3 

4793 ,case when sum(cast(hp.street0_4Bchance as <signed>integer)) = 0 then -999 

4794 else 100.0*sum(cast(hp.street0_4Bdone as <signed>integer))/sum(cast(hp.street0_4Bchance as <signed>integer)) 

4795 end AS pf4 

4796 ,case when sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) = 0 then -999 

4797 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) 

4798 end AS pff3 

4799 ,case when sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) = 0 then -999 

4800 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) 

4801 end AS pff4 

4802 ,case when sum(cast(hp.raiseFirstInChance as <signed>integer)) = 0 then -999 

4803 else 100.0 * sum(cast(hp.raisedFirstIn as <signed>integer)) /  

4804 sum(cast(hp.raiseFirstInChance as <signed>integer)) 

4805 end AS rfi 

4806 ,case when sum(cast(hp.stealChance as <signed>integer)) = 0 then -999 

4807 else 100.0 * sum(cast(hp.stealDone as <signed>integer)) /  

4808 sum(cast(hp.stealChance as <signed>integer)) 

4809 end AS steals 

4810 ,case when sum(cast(hp.stealDone as <signed>integer)) = 0 then -999 

4811 else 100.0 * sum(cast(hp.success_Steal as <signed>integer)) /  

4812 sum(cast(hp.stealDone as <signed>integer)) 

4813 end AS suc_steal 

4814 ,100.0*sum(cast(hp.street1Seen as <signed>integer))/count(1) AS saw_f 

4815 ,100.0*sum(cast(hp.sawShowdown as <signed>integer))/count(1) AS sawsd 

4816 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4817 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4818 end AS wmsf 

4819 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4820 else 100.0*sum(cast(hp.sawShowdown as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4821 end AS wtsdwsf 

4822 ,case when sum(cast(hp.sawShowdown as <signed>integer)) = 0 then -999 

4823 else 100.0*sum(cast(hp.wonAtSD as <signed>integer))/sum(cast(hp.sawShowdown as <signed>integer)) 

4824 end AS wmsd 

4825 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4826 else 100.0*sum(cast(hp.street1Aggr as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4827 end AS flafq 

4828 ,case when sum(cast(hp.street2Seen as <signed>integer)) = 0 then -999 

4829 else 100.0*sum(cast(hp.street2Aggr as <signed>integer))/sum(cast(hp.street2Seen as <signed>integer)) 

4830 end AS tuafq 

4831 ,case when sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999 

4832 else 100.0*sum(cast(hp.street3Aggr as <signed>integer))/sum(cast(hp.street3Seen as <signed>integer)) 

4833 end AS rvafq 

4834 ,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 

4835 else 100.0*(sum(cast(hp.street1Aggr as <signed>integer))+sum(cast(hp.street2Aggr as <signed>integer))+sum(cast(hp.street3Aggr as <signed>integer))) 

4836 /(sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer))) 

4837 end AS pofafq 

4838 ,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 

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

4840 /(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))) 

4841 end AS aggfac 

4842 ,case when 

4843 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))+ 

4844 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))+ 

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

4846 = 0 then -999 

4847 else 

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

4849 / ((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))) + 

4850 (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))) + 

4851 (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))) ) 

4852 end AS aggfrq 

4853 ,case when 

4854 sum(cast(hp.street1CBChance as <signed>integer))+ 

4855 sum(cast(hp.street2CBChance as <signed>integer))+ 

4856 sum(cast(hp.street3CBChance as <signed>integer))+ 

4857 sum(cast(hp.street4CBChance as <signed>integer)) = 0 then -999 

4858 else 

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

4860 / (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)))  

4861 end AS conbet 

4862 ,sum(hp.totalProfit)/100.0 AS net 

4863 ,sum(hp.rake)/100.0 AS rake 

4864 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100 

4865 ,avg(hp.totalProfit)/100.0 AS profitperhand 

4866 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr 

4867 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr 

4868 ,avg(h.seats+0.0) AS avgseats 

4869 ,variance(hp.totalProfit/100.0) AS variance 

4870 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev 

4871 from HandsPlayers hp 

4872 inner join Hands h on (h.id = hp.handId) 

4873 inner join Gametypes gt on (gt.Id = h.gametypeId) 

4874 inner join Sites s on (s.Id = gt.siteId) 

4875 inner join Players p on (p.Id = hp.playerId) 

4876 where hp.playerId in <player_test> 

4877 <game_test> 

4878 <site_test> 

4879 <currency_test> 

4880 /*and hp.tourneysPlayersId IS NULL*/ 

4881 and h.seats <seats_test> 

4882 <flagtest> 

4883 <cardstest> 

4884 <gtbigBlind_test> 

4885 and to_char(h.startTime, 'YYYY-MM-DD HH24:MI:SS') <datestest> 

4886 group by hgametypeId 

4887 ,pname 

4888 ,gt.base 

4889 ,gt.category 

4890 ,gt.ante 

4891 ,gt.currency 

4892 <groupbyseats> 

4893 ,plposition 

4894 ,upper(gt.limitType) 

4895 ,gt.fast 

4896 ,s.name 

4897 having 1 = 1 <havingclause> 

4898 order by pname 

4899 ,gt.base 

4900 ,gt.category 

4901 <orderbyseats> 

4902 ,case <position> when 'B' then 'B' 

4903 when 'S' then 'S' 

4904 when '0' then 'Y' 

4905 else 'Z'||<position> 

4906 end 

4907 <orderbyhgametypeId> 

4908 ,upper(gt.limitType) desc 

4909 ,maxbigblind desc 

4910 ,gt.fast 

4911 ,s.name 

4912 """ 

4913 elif db_server == "sqlite": 

4914 self.query["playerDetailedStats"] = """ 

4915 select <hgametypeId> AS hgametypeid 

4916 ,<playerName> AS pname 

4917 ,gt.base 

4918 ,gt.category AS category 

4919 ,upper(gt.limitType) AS limittype 

4920 ,s.name AS name 

4921 ,min(gt.bigBlind) AS minbigblind 

4922 ,max(gt.bigBlind) AS maxbigblind 

4923 ,gt.ante AS ante 

4924 ,gt.currency AS currency 

4925 /*,<hcgametypeId> AS gtid*/ 

4926 ,<position> AS plposition 

4927 ,gt.fast AS fast 

4928 ,count(1) AS n 

4929 ,case when sum(cast(hp.street0VPIChance as <signed>integer)) = 0 then -999 

4930 else 100.0*sum(cast(hp.street0VPI as <signed>integer))/sum(cast(hp.street0VPIChance as <signed>integer)) 

4931 end AS vpip 

4932 ,case when sum(cast(hp.street0AggrChance as <signed>integer)) = 0 then -999 

4933 else 100.0*sum(cast(hp.street0Aggr as <signed>integer))/sum(cast(hp.street0AggrChance as <signed>integer)) 

4934 end AS pfr 

4935 ,case when sum(cast(hp.street0CalledRaiseChance as <signed>integer)) = 0 then -999 

4936 else 100.0*sum(cast(hp.street0CalledRaiseDone as <signed>integer))/sum(cast(hp.street0CalledRaiseChance as <signed>integer)) 

4937 end AS car0 

4938 ,case when sum(cast(hp.street0_3Bchance as <signed>integer)) = 0 then -999 

4939 else 100.0*sum(cast(hp.street0_3Bdone as <signed>integer))/sum(cast(hp.street0_3Bchance as <signed>integer)) 

4940 end AS pf3 

4941 ,case when sum(cast(hp.street0_4Bchance as <signed>integer)) = 0 then -999 

4942 else 100.0*sum(cast(hp.street0_4Bdone as <signed>integer))/sum(cast(hp.street0_4Bchance as <signed>integer)) 

4943 end AS pf4 

4944 ,case when sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) = 0 then -999 

4945 else 100.0*sum(cast(hp.street0_FoldTo3Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo3Bchance as <signed>integer)) 

4946 end AS pff3 

4947 ,case when sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) = 0 then -999 

4948 else 100.0*sum(cast(hp.street0_FoldTo4Bdone as <signed>integer))/sum(cast(hp.street0_FoldTo4Bchance as <signed>integer)) 

4949 end AS pff4 

4950 ,case when sum(cast(hp.raiseFirstInChance as <signed>integer)) = 0 then -999 

4951 else 100.0 * sum(cast(hp.raisedFirstIn as <signed>integer)) /  

4952 sum(cast(hp.raiseFirstInChance as <signed>integer)) 

4953 end AS rfi 

4954 ,case when sum(cast(hp.stealChance as <signed>integer)) = 0 then -999 

4955 else 100.0 * sum(cast(hp.stealDone as <signed>integer)) /  

4956 sum(cast(hp.stealChance as <signed>integer)) 

4957 end AS steals 

4958 ,case when sum(cast(hp.stealDone as <signed>integer)) = 0 then -999 

4959 else 100.0 * sum(cast(hp.success_Steal as <signed>integer)) /  

4960 sum(cast(hp.stealDone as <signed>integer)) 

4961 end AS suc_steal 

4962 ,100.0*sum(cast(hp.street1Seen as <signed>integer))/count(1) AS saw_f 

4963 ,100.0*sum(cast(hp.sawShowdown as <signed>integer))/count(1) AS sawsd 

4964 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4965 else 100.0*sum(cast(hp.wonWhenSeenStreet1 as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4966 end AS wmsf 

4967 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4968 else 100.0*sum(cast(hp.sawShowdown as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4969 end AS wtsdwsf 

4970 ,case when sum(cast(hp.sawShowdown as <signed>integer)) = 0 then -999 

4971 else 100.0*sum(cast(hp.wonAtSD as <signed>integer))/sum(cast(hp.sawShowdown as <signed>integer)) 

4972 end AS wmsd 

4973 ,case when sum(cast(hp.street1Seen as <signed>integer)) = 0 then -999 

4974 else 100.0*sum(cast(hp.street1Aggr as <signed>integer))/sum(cast(hp.street1Seen as <signed>integer)) 

4975 end AS flafq 

4976 ,case when sum(cast(hp.street2Seen as <signed>integer)) = 0 then -999 

4977 else 100.0*sum(cast(hp.street2Aggr as <signed>integer))/sum(cast(hp.street2Seen as <signed>integer)) 

4978 end AS tuafq 

4979 ,case when sum(cast(hp.street3Seen as <signed>integer)) = 0 then -999 

4980 else 100.0*sum(cast(hp.street3Aggr as <signed>integer))/sum(cast(hp.street3Seen as <signed>integer)) 

4981 end AS rvafq 

4982 ,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 

4983 else 100.0*(sum(cast(hp.street1Aggr as <signed>integer))+sum(cast(hp.street2Aggr as <signed>integer))+sum(cast(hp.street3Aggr as <signed>integer))) 

4984 /(sum(cast(hp.street1Seen as <signed>integer))+sum(cast(hp.street2Seen as <signed>integer))+sum(cast(hp.street3Seen as <signed>integer))) 

4985 end AS pofafq 

4986 ,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 

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

4988 /(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))) 

4989 end AS aggfac 

4990 ,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)))  

4991 / ((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))) + 

4992 (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))) + 

4993 (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))) ) 

4994 AS aggfrq 

4995 ,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)))  

4996 / (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)))  

4997 AS conbet 

4998 ,sum(hp.totalProfit)/100.0 AS net 

4999 ,sum(hp.rake)/100.0 AS rake 

5000 ,100.0*avg(hp.totalProfit/(gt.bigBlind+0.0)) AS bbper100 

5001 ,avg(hp.totalProfit)/100.0 AS profitperhand 

5002 ,100.0*avg((hp.totalProfit+hp.rake)/(gt.bigBlind+0.0)) AS bb100xr 

5003 ,avg((hp.totalProfit+hp.rake)/100.0) AS profhndxr 

5004 ,avg(h.seats+0.0) AS avgseats 

5005 ,variance(hp.totalProfit/100.0) AS variance 

5006 ,sqrt(variance(hp.totalProfit/100.0)) AS stddev 

5007 from HandsPlayers hp 

5008 inner join Hands h on (h.id = hp.handId) 

5009 inner join Gametypes gt on (gt.Id = h.gametypeId) 

5010 inner join Sites s on (s.Id = gt.siteId) 

5011 inner join Players p on (p.Id = hp.playerId) 

5012 where hp.playerId in <player_test> 

5013 <game_test> 

5014 <site_test> 

5015 <currency_test> 

5016 /*and hp.tourneysPlayersId IS NULL*/ 

5017 and h.seats <seats_test> 

5018 <flagtest> 

5019 <cardstest> 

5020 <gtbigBlind_test> 

5021 and datetime(h.startTime) <datestest> 

5022 group by hgametypeId 

5023 ,hp.playerId 

5024 ,gt.base 

5025 ,gt.category 

5026 <groupbyseats> 

5027 ,plposition 

5028 ,upper(gt.limitType) 

5029 ,gt.fast 

5030 ,s.name 

5031 having 1 = 1 <havingclause> 

5032 order by hp.playerId 

5033 ,gt.base 

5034 ,gt.category 

5035 <orderbyseats> 

5036 ,case <position> when 'B' then 'B' 

5037 when 'S' then 'S' 

5038 when '0' then 'Y' 

5039 else 'Z'||<position> 

5040 end 

5041 <orderbyhgametypeId> 

5042 ,upper(gt.limitType) desc 

5043 ,max(gt.bigBlind) desc 

5044 ,gt.fast 

5045 ,s.name 

5046 """ 

5047 

5048 # FIXME: 3/4bet and foldTo don't added four tournaments yet 

5049 if db_server == "mysql": 

5050 self.query["tourneyPlayerDetailedStats"] = """ 

5051 select s.name AS siteName 

5052 ,tt.currency AS currency 

5053 ,(CASE 

5054 WHEN tt.currency = 'play' THEN tt.buyIn 

5055 ELSE tt.buyIn/100.0 

5056 END) AS buyIn 

5057 ,tt.fee/100.0 AS fee 

5058 ,tt.category AS category 

5059 ,tt.limitType AS limitType 

5060 ,tt.speed AS speed 

5061 ,tt.maxSeats AS maxSeats 

5062 ,tt.knockout AS knockout 

5063 ,tt.reEntry AS reEntry 

5064 ,p.name AS playerName 

5065 ,COUNT(1) AS tourneyCount 

5066 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS unknownRank 

5067 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS SIGNED)/CAST(COUNT(1) AS SIGNED))*100 AS itm 

5068 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS _1st 

5069 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS _2nd 

5070 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS _3rd 

5071 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS won 

5072 ,SUM(CASE 

5073 WHEN tt.currency = 'play' THEN tt.buyIn 

5074 ELSE (tt.buyIn+tt.fee)/100.0 

5075 END) AS spent 

5076 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS net 

5077 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS SIGNED)/ 

5078 CAST(SUM(tt.buyin+tt.fee) AS SIGNED))* 100.0 AS roi 

5079 ,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 

5080 from TourneysPlayers tp 

5081 inner join Tourneys t on (t.id = tp.tourneyId) 

5082 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId) 

5083 inner join Sites s on (s.Id = tt.siteId) 

5084 inner join Players p on (p.Id = tp.playerId) 

5085 where tp.playerId in <nametest> <sitetest> 

5086 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

5087 OR t.startTime is NULL) 

5088 group by tourneyTypeId, playerName 

5089 order by tourneyTypeId 

5090 ,playerName 

5091 ,siteName""" 

5092 elif db_server == "postgresql": 

5093 # sc: itm and profitPerTourney changed to "ELSE 0" to avoid divide by zero error as temp fix 

5094 # proper fix should use coalesce() or case ... when ... to work in all circumstances 

5095 self.query["tourneyPlayerDetailedStats"] = """ 

5096 select s.name AS "siteName" 

5097 ,tt.currency AS "currency" 

5098 ,(CASE 

5099 WHEN tt.currency = 'play' THEN tt.buyIn 

5100 ELSE tt.buyIn/100.0 

5101 END) AS "buyIn" 

5102 ,tt.fee/100.0 AS "fee" 

5103 ,tt.category AS "category" 

5104 ,tt.limitType AS "limitType" 

5105 ,tt.speed AS "speed" 

5106 ,tt.maxSeats AS "maxSeats" 

5107 ,tt.knockout AS "knockout" 

5108 ,tt.reEntry AS "reEntry" 

5109 ,p.name AS "playerName" 

5110 ,COUNT(1) AS "tourneyCount" 

5111 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS "unknownRank" 

5112 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS BIGINT)/CAST(COUNT(1) AS BIGINT))*100 AS itm 

5113 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS "_1st" 

5114 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS "_2nd" 

5115 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS "_3rd" 

5116 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS "won" 

5117 ,SUM(CASE 

5118 WHEN tt.currency = 'play' THEN tt.buyIn 

5119 ELSE (tt.buyIn+tt.fee)/100.0 

5120 END) AS "spent" 

5121 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS "net" 

5122 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS BIGINT)/ 

5123 CAST(SUM(tt.buyin+tt.fee) AS BIGINT))* 100.0 AS "roi" 

5124 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-(tt.buyin+tt.fee))/100.0 

5125 /(COUNT(1)-SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 0 END)) AS "profitPerTourney" 

5126 from TourneysPlayers tp 

5127 inner join Tourneys t on (t.id = tp.tourneyId) 

5128 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId) 

5129 inner join Sites s on (s.Id = tt.siteId) 

5130 inner join Players p on (p.Id = tp.playerId) 

5131 where tp.playerId in <nametest> <sitetest> 

5132 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

5133 OR t.startTime is NULL) 

5134 group by t.tourneyTypeId, s.name, p.name, tt.currency, tt.buyin, tt.fee 

5135 , tt.category, tt.limitType, tt.speed 

5136 order by t.tourneyTypeId 

5137 ,p.name 

5138 ,s.name""" 

5139 elif db_server == "sqlite": 

5140 self.query["tourneyPlayerDetailedStats"] = """ 

5141 select s.name AS siteName 

5142 ,tt.currency AS currency 

5143 ,(CASE 

5144 WHEN tt.currency = 'play' THEN tt.buyIn 

5145 ELSE tt.buyIn/100.0 

5146 END) AS buyIn 

5147 ,tt.fee/100.0 AS fee 

5148 ,tt.category AS category 

5149 ,tt.limitType AS limitType 

5150 ,tt.speed AS speed 

5151 ,tt.maxSeats AS maxSeats 

5152 ,tt.knockout AS knockout 

5153 ,tt.reEntry AS reEntry 

5154 ,p.name AS playerName 

5155 ,COUNT(1) AS tourneyCount 

5156 ,SUM(CASE WHEN tp.rank > 0 THEN 0 ELSE 1 END) AS unknownRank 

5157 ,(CAST(SUM(CASE WHEN winnings > 0 THEN 1 ELSE 0 END) AS REAL)/CAST(COUNT(1) AS REAL))*100 AS itm 

5158 ,SUM(CASE WHEN rank = 1 THEN 1 ELSE 0 END) AS _1st 

5159 ,SUM(CASE WHEN rank = 2 THEN 1 ELSE 0 END) AS _2nd 

5160 ,SUM(CASE WHEN rank = 3 THEN 1 ELSE 0 END) AS _3rd 

5161 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0))/100.0 AS won 

5162 ,SUM(CASE 

5163 WHEN tt.currency = 'play' THEN tt.buyIn 

5164 ELSE (tt.buyIn+tt.fee)/100.0 

5165 END) AS spent 

5166 ,SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0)-tt.buyIn-tt.fee)/100.0 AS net 

5167 ,(CAST(SUM(tp.winnings+COALESCE(tp.koCount*tt.koBounty,0) - tt.buyin - tt.fee) AS REAL)/ 

5168 CAST(SUM(tt.buyin+tt.fee) AS REAL))* 100.0 AS roi 

5169 ,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 

5170 from TourneysPlayers tp 

5171 inner join Tourneys t on (t.id = tp.tourneyId) 

5172 inner join TourneyTypes tt on (tt.Id = t.tourneyTypeId) 

5173 inner join Sites s on (s.Id = tt.siteId) 

5174 inner join Players p on (p.Id = tp.playerId) 

5175 where tp.playerId in <nametest> <sitetest> 

5176 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

5177 OR t.startTime is NULL) 

5178 group by tourneyTypeId, playerName 

5179 order by tourneyTypeId 

5180 ,playerName 

5181 ,siteName""" 

5182 

5183 if db_server == "mysql": 

5184 self.query["playerStats"] = """ 

5185 SELECT 

5186 concat(upper(stats.limitType), ' ' 

5187 ,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' ' 

5188 ,stats.name, ' ' 

5189 ,cast(stats.bigBlindDesc as char) 

5190 ) AS Game 

5191 ,stats.n 

5192 ,stats.vpip 

5193 ,stats.pfr 

5194 ,stats.pf3 

5195 ,stats.pf4 

5196 ,stats.pff3 

5197 ,stats.pff4 

5198 ,stats.steals 

5199 ,stats.saw_f 

5200 ,stats.sawsd 

5201 ,stats.wtsdwsf 

5202 ,stats.wmsd 

5203 ,stats.FlAFq 

5204 ,stats.TuAFq 

5205 ,stats.RvAFq 

5206 ,stats.PoFAFq 

5207 ,stats.Net 

5208 ,stats.BBper100 

5209 ,stats.Profitperhand 

5210 ,case when hprof2.variance = -999 then '-' 

5211 else format(hprof2.variance, 2) 

5212 end AS Variance 

5213 ,case when hprof2.stddev = -999 then '-' 

5214 else format(hprof2.stddev, 2) 

5215 end AS Stddev 

5216 ,stats.AvgSeats 

5217 FROM 

5218 (select /* stats from hudcache */ 

5219 gt.base 

5220 ,gt.category 

5221 ,upper(gt.limitType) as limitType 

5222 ,s.name 

5223 ,<selectgt.bigBlind> AS bigBlindDesc 

5224 ,<hcgametypeId> AS gtId 

5225 ,sum(n) AS n 

5226 ,case when sum(street0VPIChance) = 0 then '0' 

5227 else format(100.0*sum(street0VPI)/sum(street0VPIChance),1) 

5228 end AS vpip 

5229 ,case when sum(street0AggrChance) = 0 then '0' 

5230 else format(100.0*sum(street0Aggr)/sum(street0AggrChance),1) 

5231 end AS pfr 

5232 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5233 else format(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1) 

5234 end AS car0 

5235 ,case when sum(street0_3Bchance) = 0 then '0' 

5236 else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) 

5237 end AS pf3 

5238 ,case when sum(street0_4Bchance) = 0 then '0' 

5239 else format(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1) 

5240 end AS pf4 

5241 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5242 else format(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1) 

5243 end AS pff3 

5244 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5245 else format(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1) 

5246 end AS pff4 

5247 ,case when sum(raiseFirstInChance) = 0 then '-' 

5248 else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) 

5249 end AS steals 

5250 ,format(100.0*sum(street1Seen)/sum(n),1) AS saw_f 

5251 ,format(100.0*sum(sawShowdown)/sum(n),1) AS sawsd 

5252 ,case when sum(street1Seen) = 0 then '-' 

5253 else format(100.0*sum(sawShowdown)/sum(street1Seen),1) 

5254 end AS wtsdwsf 

5255 ,case when sum(sawShowdown) = 0 then '-' 

5256 else format(100.0*sum(wonAtSD)/sum(sawShowdown),1) 

5257 end AS wmsd 

5258 ,case when sum(street1Seen) = 0 then '-' 

5259 else format(100.0*sum(street1Aggr)/sum(street1Seen),1) 

5260 end AS FlAFq 

5261 ,case when sum(street2Seen) = 0 then '-' 

5262 else format(100.0*sum(street2Aggr)/sum(street2Seen),1) 

5263 end AS TuAFq 

5264 ,case when sum(street3Seen) = 0 then '-' 

5265 else format(100.0*sum(street3Aggr)/sum(street3Seen),1) 

5266 end AS RvAFq 

5267 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5268 else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5269 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1) 

5270 end AS PoFAFq 

5271 ,format(sum(totalProfit)/100.0,2) AS Net 

5272 ,format((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2) 

5273 AS BBper100 

5274 ,format( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand 

5275 ,format( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats 

5276 from Gametypes gt 

5277 inner join Sites s on s.Id = gt.siteId 

5278 inner join HudCache hc on hc.gametypeId = gt.Id 

5279 where hc.playerId in <player_test> 

5280 <gtbigBlind_test> 

5281 and hc.seats <seats_test> 

5282 and concat( '20', substring(hc.styleKey,2,2), '-', substring(hc.styleKey,4,2), '-' 

5283 , substring(hc.styleKey,6,2) ) <datestest> 

5284 group by gt.base 

5285 ,gt.category 

5286 ,upper(gt.limitType) 

5287 ,s.name 

5288 <groupbygt.bigBlind> 

5289 ,gtId 

5290 ) stats 

5291 inner join 

5292 ( select # profit from handsplayers/handsactions 

5293 hprof.gtId, sum(hprof.profit) sum_profit, 

5294 avg(hprof.profit/100.0) profitperhand, 

5295 case when hprof.gtId = -1 then -999 

5296 else variance(hprof.profit/100.0) 

5297 end as variance 

5298 ,sqrt(variance(hprof.profit/100.0)) AS stddev 

5299 from 

5300 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit 

5301 from HandsPlayers hp 

5302 inner join Hands h ON h.id = hp.handId 

5303 where hp.playerId in <player_test> 

5304 and hp.tourneysPlayersId IS NULL 

5305 and date_format(h.startTime, '%Y-%m-%d') <datestest> 

5306 group by hp.handId, gtId, hp.totalProfit 

5307 ) hprof 

5308 group by hprof.gtId 

5309 ) hprof2 

5310 on hprof2.gtId = stats.gtId 

5311 order by stats.category, stats.limittype, stats.bigBlindDesc desc <orderbyseats>""" 

5312 elif db_server == "sqlite": 

5313 self.query["playerStats"] = """ 

5314 SELECT 

5315 upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' ' || 

5316 stats.name || ' ' || 

5317 cast(stats.bigBlindDesc as char) || ' ' || stats.maxSeats || ' seat' AS Game 

5318 ,stats.n,stats.vpip,stats.pfr,stats.pf3,stats.pf4,stats.pff3,stats.pff4 

5319 ,stats.steals,stats.saw_f,stats.sawsd,stats.wtsdwsf,stats.wmsd,stats.FlAFq 

5320 ,stats.TuAFq,stats.RvAFq,stats.PoFAFq,stats.Net,stats.BBper100,stats.Profitperhand 

5321 ,case when hprof2.variance = -999 then '-' else round(hprof2.variance, 2) 

5322 end AS Variance 

5323 ,case when hprof2.stddev = -999 then '-' else round(hprof2.stddev, 2) 

5324 end AS Stddev 

5325 ,stats.AvgSeats 

5326 FROM 

5327 (select /* stats from hudcache */ 

5328 gt.base 

5329 ,gt.category,maxSeats,gt.bigBlind,gt.currency 

5330 ,upper(gt.limitType) AS limitType 

5331 ,s.name 

5332 ,<selectgt.bigBlind> AS bigBlindDesc 

5333 ,<hcgametypeId> AS gtId 

5334 ,sum(n) AS n 

5335 ,case when sum(street0VPIChance) = 0 then '0' 

5336 else round(100.0*sum(street0VPI)/sum(street0VPIChance),1) 

5337 end AS vpip 

5338 ,case when sum(street0AggrChance) = 0 then '0' 

5339 else round(100.0*sum(street0Aggr)/sum(street0AggrChance),1) 

5340 end AS pfr 

5341 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5342 else round(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1) 

5343 end AS car0 

5344 ,case when sum(street0_3Bchance) = 0 then '0' 

5345 else round(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) 

5346 end AS pf3 

5347 ,case when sum(street0_4Bchance) = 0 then '0' 

5348 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1) 

5349 end AS pf4 

5350 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5351 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1) 

5352 end AS pff3 

5353 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5354 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1) 

5355 end AS pff4 

5356 ,case when sum(raiseFirstInChance) = 0 then '-' 

5357 else round(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) 

5358 end AS steals 

5359 ,round(100.0*sum(street1Seen)/sum(n),1) AS saw_f 

5360 ,round(100.0*sum(sawShowdown)/sum(n),1) AS sawsd 

5361 ,case when sum(street1Seen) = 0 then '-' 

5362 else round(100.0*sum(sawShowdown)/sum(street1Seen),1) 

5363 end AS wtsdwsf 

5364 ,case when sum(sawShowdown) = 0 then '-' 

5365 else round(100.0*sum(wonAtSD)/sum(sawShowdown),1) 

5366 end AS wmsd 

5367 ,case when sum(street1Seen) = 0 then '-' 

5368 else round(100.0*sum(street1Aggr)/sum(street1Seen),1) 

5369 end AS FlAFq 

5370 ,case when sum(street2Seen) = 0 then '-' 

5371 else round(100.0*sum(street2Aggr)/sum(street2Seen),1) 

5372 end AS TuAFq 

5373 ,case when sum(street3Seen) = 0 then '-' 

5374 else round(100.0*sum(street3Aggr)/sum(street3Seen),1) 

5375 end AS RvAFq 

5376 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5377 else round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5378 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1) 

5379 end AS PoFAFq 

5380 ,round(sum(totalProfit)/100.0,2) AS Net 

5381 ,round((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2) 

5382 AS BBper100 

5383 ,round( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand 

5384 ,round( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats 

5385 from Gametypes gt 

5386 inner join Sites s on s.Id = gt.siteId 

5387 inner join HudCache hc on hc.gametypeId = gt.Id 

5388 where hc.playerId in <player_test> 

5389 <gtbigBlind_test> 

5390 and hc.seats <seats_test> 

5391 and '20' || substr(hc.styleKey,2,2) || '-' || substr(hc.styleKey,4,2) || '-' || 

5392 substr(hc.styleKey,6,2) <datestest> 

5393 group by gt.base,gt.category,upper(gt.limitType),s.name <groupbygt.bigBlind>,gtId 

5394 ) stats 

5395 inner join 

5396 ( select /* profit from handsplayers/handsactions */ 

5397 hprof.gtId, sum(hprof.profit) sum_profit, 

5398 avg(hprof.profit/100.0) profitperhand, 

5399 case when hprof.gtId = -1 then -999 

5400 else variance(hprof.profit/100.0) 

5401 end as variance 

5402 ,case when hprof.gtId = -1 then -999 

5403 else sqrt(variance(hprof.profit/100.0)) 

5404 end as stddev 

5405 from 

5406 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit 

5407 from HandsPlayers hp 

5408 inner join Hands h ON h.id = hp.handId 

5409 where hp.playerId in <player_test> 

5410 and hp.tourneysPlayersId IS NULL 

5411 and datetime(h.startTime) <datestest> 

5412 group by hp.handId, gtId, hp.totalProfit 

5413 ) hprof 

5414 group by hprof.gtId 

5415 ) hprof2 

5416 on hprof2.gtId = stats.gtId 

5417 order by stats.category, stats.bigBlind, stats.limittype, stats.currency, stats.maxSeats <orderbyseats>""" 

5418 else: # assume postgres 

5419 self.query["playerStats"] = """ 

5420 SELECT upper(stats.limitType) || ' ' 

5421 || initcap(stats.category) || ' ' 

5422 || stats.name || ' ' 

5423 || stats.bigBlindDesc AS Game 

5424 ,stats.n 

5425 ,stats.vpip 

5426 ,stats.pfr 

5427 ,stats.pf3 

5428 ,stats.pf4 

5429 ,stats.pff3 

5430 ,stats.pff4 

5431 ,stats.steals 

5432 ,stats.saw_f 

5433 ,stats.sawsd 

5434 ,stats.wtsdwsf 

5435 ,stats.wmsd 

5436 ,stats.FlAFq 

5437 ,stats.TuAFq 

5438 ,stats.RvAFq 

5439 ,stats.PoFAFq 

5440 ,stats.Net 

5441 ,stats.BBper100 

5442 ,stats.Profitperhand 

5443 ,case when hprof2.variance = -999 then '-' 

5444 else to_char(hprof2.variance, '0D00') 

5445 end AS Variance 

5446 ,case when hprof2.stddev = -999 then '-' 

5447 else to_char(hprof2.stddev, '0D00') 

5448 end AS Stddev 

5449 ,AvgSeats 

5450 FROM 

5451 (select gt.base 

5452 ,gt.category 

5453 ,upper(gt.limitType) AS limitType 

5454 ,s.name 

5455 ,<selectgt.bigBlind> AS bigBlindDesc 

5456 ,<hcgametypeId> AS gtId 

5457 ,sum(n) AS n 

5458 ,case when sum(street0VPIChance) = 0 then '0' 

5459 else to_char(100.0*sum(street0VPI)/sum(street0VPIChance),'990D0') 

5460 end AS vpip 

5461 ,case when sum(street0AggrChance) = 0 then '0' 

5462 else to_char(100.0*sum(street0Aggr)/sum(street0AggrChance),'90D0') 

5463 end AS pfr 

5464 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5465 else to_char(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),'90D0') 

5466 end AS car0 

5467 ,case when sum(street0_3Bchance) = 0 then '0' 

5468 else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0') 

5469 end AS pf3 

5470 ,case when sum(street0_4Bchance) = 0 then '0' 

5471 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1) 

5472 end AS pf4 

5473 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5474 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1) 

5475 end AS pff3 

5476 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5477 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1) 

5478 end AS pff4 

5479 ,case when sum(raiseFirstInChance) = 0 then '-' 

5480 else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0') 

5481 end AS steals 

5482 ,to_char(100.0*sum(street1Seen)/sum(n),'90D0') AS saw_f 

5483 ,to_char(100.0*sum(sawShowdown)/sum(n),'90D0') AS sawsd 

5484 ,case when sum(street1Seen) = 0 then '-' 

5485 else to_char(100.0*sum(sawShowdown)/sum(street1Seen),'90D0') 

5486 end AS wtsdwsf 

5487 ,case when sum(sawShowdown) = 0 then '-' 

5488 else to_char(100.0*sum(wonAtSD)/sum(sawShowdown),'90D0') 

5489 end AS wmsd 

5490 ,case when sum(street1Seen) = 0 then '-' 

5491 else to_char(100.0*sum(street1Aggr)/sum(street1Seen),'90D0') 

5492 end AS FlAFq 

5493 ,case when sum(street2Seen) = 0 then '-' 

5494 else to_char(100.0*sum(street2Aggr)/sum(street2Seen),'90D0') 

5495 end AS TuAFq 

5496 ,case when sum(street3Seen) = 0 then '-' 

5497 else to_char(100.0*sum(street3Aggr)/sum(street3Seen),'90D0') 

5498 end AS RvAFq 

5499 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5500 else to_char(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5501 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),'90D0') 

5502 end AS PoFAFq 

5503 ,round(sum(totalProfit)/100.0,2) AS Net 

5504 ,to_char((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0), '990D00') 

5505 AS BBper100 

5506 ,to_char(sum(totalProfit/100.0) / (sum(n)+0.0), '990D0000') AS Profitperhand 

5507 ,to_char(sum(seats*n)/(sum(n)+0.0),'90D00') AS AvgSeats 

5508 from Gametypes gt 

5509 inner join Sites s on s.Id = gt.siteId 

5510 inner join HudCache hc on hc.gametypeId = gt.Id 

5511 where hc.playerId in <player_test> 

5512 <gtbigBlind_test> 

5513 and hc.seats <seats_test> 

5514 and '20' || SUBSTR(hc.styleKey,2,2) || '-' || SUBSTR(hc.styleKey,4,2) || '-' 

5515 || SUBSTR(hc.styleKey,6,2) <datestest> 

5516 group by gt.base 

5517 ,gt.category 

5518 ,upper(gt.limitType) 

5519 ,s.name 

5520 <groupbygt.bigBlind> 

5521 ,gtId 

5522 ) stats 

5523 inner join 

5524 ( select 

5525 hprof.gtId, sum(hprof.profit) AS sum_profit, 

5526 avg(hprof.profit/100.0) AS profitperhand, 

5527 case when hprof.gtId = -1 then -999 

5528 else variance(hprof.profit/100.0) 

5529 end as variance 

5530 ,case when hprof.gtId = -1 then -999 

5531 else sqrt(variance(hprof.profit/100.0)) 

5532 end as stddev 

5533 from 

5534 (select hp.handId, <hgametypeId> as gtId, hp.totalProfit as profit 

5535 from HandsPlayers hp 

5536 inner join Hands h ON (h.id = hp.handId) 

5537 where hp.playerId in <player_test> 

5538 and hp.tourneysPlayersId IS NULL 

5539 and to_char(h.startTime, 'YYYY-MM-DD') <datestest> 

5540 group by hp.handId, gtId, hp.totalProfit 

5541 ) hprof 

5542 group by hprof.gtId 

5543 ) hprof2 

5544 on hprof2.gtId = stats.gtId 

5545 order by stats.base, stats.limittype, stats.bigBlindDesc desc <orderbyseats>""" 

5546 

5547 if db_server == "mysql": 

5548 self.query["playerStatsByPosition"] = """ 

5549 SELECT 

5550 concat(upper(stats.limitType), ' ' 

5551 ,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' ' 

5552 ,stats.name, ' ' 

5553 ,cast(stats.bigBlindDesc as char) 

5554 ) AS Game 

5555 ,case when stats.PlPosition = -2 then 'BB' 

5556 when stats.PlPosition = -1 then 'SB' 

5557 when stats.PlPosition = 0 then 'Btn' 

5558 when stats.PlPosition = 1 then 'CO' 

5559 when stats.PlPosition = 2 then 'MP' 

5560 when stats.PlPosition = 5 then 'EP' 

5561 else 'xx' 

5562 end AS PlPosition 

5563 ,stats.n 

5564 ,stats.vpip 

5565 ,stats.pfr 

5566 ,stats.car0 

5567 ,stats.pf3 

5568 ,stats.pf4 

5569 ,stats.pff3 

5570 ,stats.pff4 

5571 ,stats.steals 

5572 ,stats.saw_f 

5573 ,stats.sawsd 

5574 ,stats.wtsdwsf 

5575 ,stats.wmsd 

5576 ,stats.FlAFq 

5577 ,stats.TuAFq 

5578 ,stats.RvAFq 

5579 ,stats.PoFAFq 

5580 ,stats.Net 

5581 ,stats.BBper100 

5582 ,stats.Profitperhand 

5583 ,case when hprof2.variance = -999 then '-' 

5584 else format(hprof2.variance, 2) 

5585 end AS Variance 

5586 ,case when hprof2.stddev = -999 then '-' 

5587 else format(hprof2.stddev, 2) 

5588 end AS Stddev 

5589 ,stats.AvgSeats 

5590 FROM 

5591 (select /* stats from hudcache */ 

5592 gt.base 

5593 ,gt.category 

5594 ,upper(gt.limitType) AS limitType 

5595 ,s.name 

5596 ,<selectgt.bigBlind> AS bigBlindDesc 

5597 ,<hcgametypeId> AS gtId 

5598 ,case when hc.position = 'B' then -2 

5599 when hc.position = 'S' then -1 

5600 when hc.position = 'D' then 0 

5601 when hc.position = 'C' then 1 

5602 when hc.position = 'M' then 2 

5603 when hc.position = 'E' then 5 

5604 else 9 

5605 end as PlPosition 

5606 ,sum(n) AS n 

5607 ,case when sum(street0VPIChance) = 0 then '0' 

5608 else format(100.0*sum(street0VPI)/sum(street0VPIChance),1) 

5609 end AS vpip 

5610 ,case when sum(street0AggrChance) = 0 then '0' 

5611 else format(100.0*sum(street0Aggr)/sum(street0AggrChance),1) 

5612 end AS pfr 

5613 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5614 else format(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1) 

5615 end AS car0 

5616 ,case when sum(street0_3Bchance) = 0 then '0' 

5617 else format(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) 

5618 end AS pf3 

5619 ,case when sum(street0_4Bchance) = 0 then '0' 

5620 else format(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1) 

5621 end AS pf4 

5622 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5623 else format(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1) 

5624 end AS pff3 

5625 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5626 else format(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1) 

5627 end AS pff4 

5628 ,case when sum(raiseFirstInChance) = 0 then '-' 

5629 else format(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) 

5630 end AS steals 

5631 ,format(100.0*sum(street1Seen)/sum(n),1) AS saw_f 

5632 ,format(100.0*sum(sawShowdown)/sum(n),1) AS sawsd 

5633 ,case when sum(street1Seen) = 0 then '-' 

5634 else format(100.0*sum(sawShowdown)/sum(street1Seen),1) 

5635 end AS wtsdwsf 

5636 ,case when sum(sawShowdown) = 0 then '-' 

5637 else format(100.0*sum(wonAtSD)/sum(sawShowdown),1) 

5638 end AS wmsd 

5639 ,case when sum(street1Seen) = 0 then '-' 

5640 else format(100.0*sum(street1Aggr)/sum(street1Seen),1) 

5641 end AS FlAFq 

5642 ,case when sum(street2Seen) = 0 then '-' 

5643 else format(100.0*sum(street2Aggr)/sum(street2Seen),1) 

5644 end AS TuAFq 

5645 ,case when sum(street3Seen) = 0 then '-' 

5646 else format(100.0*sum(street3Aggr)/sum(street3Seen),1) 

5647 end AS RvAFq 

5648 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5649 else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5650 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1) 

5651 end AS PoFAFq 

5652 ,format(sum(totalProfit)/100.0,2) AS Net 

5653 ,format((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2) 

5654 AS BBper100 

5655 ,format( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand 

5656 ,format( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats 

5657 from Gametypes gt 

5658 inner join Sites s on s.Id = gt.siteId 

5659 inner join HudCache hc on hc.gametypeId = gt.Id 

5660 where hc.playerId in <player_test> 

5661 <gtbigBlind_test> 

5662 and hc.seats <seats_test> 

5663 and concat( '20', substring(hc.styleKey,2,2), '-', substring(hc.styleKey,4,2), '-' 

5664 , substring(hc.styleKey,6,2) ) <datestest> 

5665 group by gt.base 

5666 ,gt.category 

5667 ,upper(gt.limitType) 

5668 ,s.name 

5669 <groupbygt.bigBlind> 

5670 ,gtId 

5671 <groupbyseats> 

5672 ,PlPosition 

5673 ) stats 

5674 inner join 

5675 ( select # profit from handsplayers/handsactions 

5676 hprof.gtId, 

5677 case when hprof.position = 'B' then -2 

5678 when hprof.position = 'S' then -1 

5679 when hprof.position in ('3','4') then 2 

5680 when hprof.position in ('6','7') then 5 

5681 else hprof.position 

5682 end as PlPosition, 

5683 sum(hprof.profit) as sum_profit, 

5684 avg(hprof.profit/100.0) as profitperhand, 

5685 case when hprof.gtId = -1 then -999 

5686 else variance(hprof.profit/100.0) 

5687 end as variance 

5688 ,case when hprof.gtId = -1 then -999 

5689 else sqrt(variance(hprof.profit/100.0)) 

5690 end as stddev 

5691 from 

5692 (select hp.handId, <hgametypeId> as gtId, hp.position 

5693 , hp.totalProfit as profit 

5694 from HandsPlayers hp 

5695 inner join Hands h ON (h.id = hp.handId) 

5696 where hp.playerId in <player_test> 

5697 and hp.tourneysPlayersId IS NULL 

5698 and date_format(h.startTime, '%Y-%m-%d') <datestest> 

5699 group by hp.handId, gtId, hp.position, hp.totalProfit 

5700 ) hprof 

5701 group by hprof.gtId, PlPosition 

5702 ) hprof2 

5703 on ( hprof2.gtId = stats.gtId 

5704 and hprof2.PlPosition = stats.PlPosition) 

5705 order by stats.category, stats.limitType, stats.bigBlindDesc desc 

5706 <orderbyseats>, cast(stats.PlPosition as signed) 

5707 """ 

5708 elif db_server == "sqlite": 

5709 self.query["playerStatsByPosition"] = """ 

5710 SELECT 

5711 upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' ' || 

5712 stats.name || ' ' || 

5713 cast(stats.bigBlindDesc as char) || ' ' || stats.maxSeats || ' seat' AS Game 

5714 ,case when stats.PlPosition = -2 then 'BB' 

5715 when stats.PlPosition = -1 then 'SB' 

5716 when stats.PlPosition = 0 then 'Btn' 

5717 when stats.PlPosition = 1 then 'CO' 

5718 when stats.PlPosition = 2 then 'MP' 

5719 when stats.PlPosition = 5 then 'EP' 

5720 else 'xx' 

5721 end AS PlPosition 

5722 ,stats.n,stats.vpip,stats.pfr,stats.pf3,stats.pf4,stats.pff3,stats.pff4 

5723 ,stats.steals,stats.saw_f,stats.sawsd,stats.wtsdwsf,stats.wmsd,stats.FlAFq 

5724 ,stats.TuAFq,stats.RvAFq,stats.PoFAFq,stats.Net,stats.BBper100,stats.Profitperhand 

5725 ,case when hprof2.variance = -999 then '-' 

5726 else round(hprof2.variance, 2) 

5727 end AS Variance 

5728 ,case when hprof2.variance = -999 then '-' 

5729 else round(hprof2.stddev, 2) 

5730 end AS Stddev 

5731 ,stats.AvgSeats 

5732 FROM 

5733 (select /* stats from hudcache */ 

5734 gt.base 

5735 ,gt.category,maxSeats,gt.bigBlind,gt.currency 

5736 ,upper(gt.limitType) AS limitType 

5737 ,s.name 

5738 ,<selectgt.bigBlind> AS bigBlindDesc 

5739 ,<hcgametypeId> AS gtId 

5740 ,case when hc.position = 'B' then -2 

5741 when hc.position = 'S' then -1 

5742 when hc.position = 'D' then 0 

5743 when hc.position = 'C' then 1 

5744 when hc.position = 'M' then 2 

5745 when hc.position = 'E' then 5 

5746 else 9 

5747 end AS PlPosition 

5748 ,sum(n) AS n 

5749 ,case when sum(street0VPIChance) = 0 then '0' 

5750 else round(100.0*sum(street0VPI)/sum(street0VPIChance),1) 

5751 end AS vpip 

5752 ,case when sum(street0AggrChance) = 0 then '0' 

5753 else round(100.0*sum(street0Aggr)/sum(street0AggrChance),1) 

5754 end AS pfr 

5755 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5756 else round(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),1) 

5757 end AS car0 

5758 ,case when sum(street0_3Bchance) = 0 then '0' 

5759 else round(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),1) 

5760 end AS pf3 

5761 ,case when sum(street0_4Bchance) = 0 then '0' 

5762 else round(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),1) 

5763 end AS pf4 

5764 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5765 else round(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),1) 

5766 end AS pff3 

5767 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5768 else round(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),1) 

5769 end AS pff4 

5770 ,case when sum(raiseFirstInChance) = 0 then '-' 

5771 else round(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),1) 

5772 end AS steals 

5773 ,round(100.0*sum(street1Seen)/sum(n),1) AS saw_f 

5774 ,round(100.0*sum(sawShowdown)/sum(n),1) AS sawsd 

5775 ,case when sum(street1Seen) = 0 then '-' 

5776 else round(100.0*sum(sawShowdown)/sum(street1Seen),1) 

5777 end AS wtsdwsf 

5778 ,case when sum(sawShowdown) = 0 then '-' 

5779 else round(100.0*sum(wonAtSD)/sum(sawShowdown),1) 

5780 end AS wmsd 

5781 ,case when sum(street1Seen) = 0 then '-' 

5782 else round(100.0*sum(street1Aggr)/sum(street1Seen),1) 

5783 end AS FlAFq 

5784 ,case when sum(street2Seen) = 0 then '-' 

5785 else round(100.0*sum(street2Aggr)/sum(street2Seen),1) 

5786 end AS TuAFq 

5787 ,case when sum(street3Seen) = 0 then '-' 

5788 else round(100.0*sum(street3Aggr)/sum(street3Seen),1) 

5789 end AS RvAFq 

5790 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5791 else round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5792 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1) 

5793 end AS PoFAFq 

5794 ,round(sum(totalProfit)/100.0,2) AS Net 

5795 ,round((sum(totalProfit/(gt.bigBlind+0.0))) / (sum(n)/100.0),2) 

5796 AS BBper100 

5797 ,round( (sum(totalProfit)/100.0) / sum(n), 4) AS Profitperhand 

5798 ,round( sum(seats*n)/(sum(n)+0.0), 2) AS AvgSeats 

5799 from Gametypes gt 

5800 inner join Sites s on s.Id = gt.siteId 

5801 inner join HudCache hc on hc.gametypeId = gt.Id 

5802 where hc.playerId in <player_test> 

5803 <gtbigBlind_test> 

5804 and hc.seats <seats_test> 

5805 and '20' || substr(hc.styleKey,2,2) || '-' || substr(hc.styleKey,4,2) || '-' || 

5806 substr(hc.styleKey,6,2) <datestest> 

5807 group by gt.base,gt.category,upper(gt.limitType),s.name 

5808 <groupbygt.bigBlind>,gtId<groupbyseats>,PlPosition 

5809 ) stats 

5810 inner join 

5811 ( select /* profit from handsplayers/handsactions */ 

5812 hprof.gtId, 

5813 cast(case when hprof.position = 'B' then -2 

5814 when hprof.position = 'S' then -1 

5815 when hprof.position in ('3','4') then 2 

5816 when hprof.position in ('6','7') then 5 

5817 else hprof.position 

5818 end as signed) as PlPosition, 

5819 sum(hprof.profit) as sum_profit, 

5820 avg(hprof.profit/100.0) as profitperhand, 

5821 case when hprof.gtId = -1 then -999 

5822 else variance(hprof.profit/100.0) 

5823 end as variance 

5824 ,case when hprof.gtId = -1 then -999 

5825 else sqrt(variance(hprof.profit/100.0)) 

5826 end as stddev 

5827 from 

5828 (select hp.handId, <hgametypeId> as gtId, hp.position 

5829 , hp.totalProfit as profit 

5830 from HandsPlayers hp 

5831 inner join Hands h ON (h.id = hp.handId) 

5832 where hp.playerId in <player_test> 

5833 and hp.tourneysPlayersId IS NULL 

5834 and datetime(h.startTime) <datestest> 

5835 group by hp.handId, gtId, hp.position, hp.totalProfit 

5836 ) hprof 

5837 group by hprof.gtId, PlPosition 

5838 ) hprof2 

5839 on ( hprof2.gtId = stats.gtId 

5840 and hprof2.PlPosition = stats.PlPosition) 

5841 order by stats.category, stats.bigBlind, stats.limitType, stats.currency, stats.maxSeats <orderbyseats> 

5842 ,cast(stats.PlPosition as signed) 

5843 """ 

5844 else: # assume postgresql 

5845 self.query["playerStatsByPosition"] = """ 

5846 select /* stats from hudcache */ 

5847 upper(stats.limitType) || ' ' 

5848 || upper(substr(stats.category,1,1)) || substr(stats.category,2) || ' ' 

5849 || stats.name || ' ' 

5850 || stats.bigBlindDesc AS Game 

5851 ,case when stats.PlPosition = -2 then 'BB' 

5852 when stats.PlPosition = -1 then 'SB' 

5853 when stats.PlPosition = 0 then 'Btn' 

5854 when stats.PlPosition = 1 then 'CO' 

5855 when stats.PlPosition = 2 then 'MP' 

5856 when stats.PlPosition = 5 then 'EP' 

5857 else 'xx' 

5858 end AS PlPosition 

5859 ,stats.n 

5860 ,stats.vpip 

5861 ,stats.pfr 

5862 ,stats.pf3 

5863 ,stats.pf4 

5864 ,stats.pff3 

5865 ,stats.pff4 

5866 ,stats.steals 

5867 ,stats.saw_f 

5868 ,stats.sawsd 

5869 ,stats.wtsdwsf 

5870 ,stats.wmsd 

5871 ,stats.FlAFq 

5872 ,stats.TuAFq 

5873 ,stats.RvAFq 

5874 ,stats.PoFAFq 

5875 ,stats.Net 

5876 ,stats.BBper100 

5877 ,stats.Profitperhand 

5878 ,case when hprof2.variance = -999 then '-' 

5879 else to_char(hprof2.variance, '0D00') 

5880 end AS Variance 

5881 ,case when hprof2.stddev = -999 then '-' 

5882 else to_char(hprof2.stddev, '0D00') 

5883 end AS Stddev 

5884 ,stats.AvgSeats 

5885 FROM 

5886 (select /* stats from hudcache */ 

5887 gt.base 

5888 ,gt.category 

5889 ,upper(gt.limitType) AS limitType 

5890 ,s.name 

5891 ,<selectgt.bigBlind> AS bigBlindDesc 

5892 ,<hcgametypeId> AS gtId 

5893 ,case when hc.position = 'B' then -2 

5894 when hc.position = 'S' then -1 

5895 when hc.position = 'D' then 0 

5896 when hc.position = 'C' then 1 

5897 when hc.position = 'M' then 2 

5898 when hc.position = 'E' then 5 

5899 else 9 

5900 end AS PlPosition 

5901 ,sum(n) AS n 

5902 ,case when sum(street0VPIChance) = 0 then '0' 

5903 else to_char(100.0*sum(street0VPI)/sum(street0VPIChance),'990D0') 

5904 end AS vpip 

5905 ,case when sum(street0AggrChance) = 0 then '0' 

5906 else to_char(100.0*sum(street0Aggr)/sum(street0AggrChance),'90D0') 

5907 end AS pfr 

5908 ,case when sum(street0CalledRaiseChance) = 0 then '0' 

5909 else to_char(100.0*sum(street0CalledRaiseDone)/sum(street0CalledRaiseChance),'90D0') 

5910 end AS car0 

5911 ,case when sum(street0_3Bchance) = 0 then '0' 

5912 else to_char(100.0*sum(street0_3Bdone)/sum(street0_3Bchance),'90D0') 

5913 end AS pf3 

5914 ,case when sum(street0_4Bchance) = 0 then '0' 

5915 else to_char(100.0*sum(street0_4Bdone)/sum(street0_4Bchance),'90D0') 

5916 end AS pf4 

5917 ,case when sum(street0_FoldTo3Bchance) = 0 then '0' 

5918 else to_char(100.0*sum(street0_FoldTo3Bdone)/sum(street0_FoldTo3Bchance),'90D0') 

5919 end AS pff3 

5920 ,case when sum(street0_FoldTo4Bchance) = 0 then '0' 

5921 else to_char(100.0*sum(street0_FoldTo4Bdone)/sum(street0_FoldTo4Bchance),'90D0') 

5922 end AS pff4 

5923 ,case when sum(raiseFirstInChance) = 0 then '-' 

5924 else to_char(100.0*sum(raisedFirstIn)/sum(raiseFirstInChance),'90D0') 

5925 end AS steals 

5926 ,to_char(round(100.0*sum(street1Seen)/sum(n)),'90D0') AS saw_f 

5927 ,to_char(round(100.0*sum(sawShowdown)/sum(n)),'90D0') AS sawsd 

5928 ,case when sum(street1Seen) = 0 then '-' 

5929 else to_char(round(100.0*sum(sawShowdown)/sum(street1Seen)),'90D0') 

5930 end AS wtsdwsf 

5931 ,case when sum(sawShowdown) = 0 then '-' 

5932 else to_char(round(100.0*sum(wonAtSD)/sum(sawShowdown)),'90D0') 

5933 end AS wmsd 

5934 ,case when sum(street1Seen) = 0 then '-' 

5935 else to_char(round(100.0*sum(street1Aggr)/sum(street1Seen)),'90D0') 

5936 end AS FlAFq 

5937 ,case when sum(street2Seen) = 0 then '-' 

5938 else to_char(round(100.0*sum(street2Aggr)/sum(street2Seen)),'90D0') 

5939 end AS TuAFq 

5940 ,case when sum(street3Seen) = 0 then '-' 

5941 else to_char(round(100.0*sum(street3Aggr)/sum(street3Seen)),'90D0') 

5942 end AS RvAFq 

5943 ,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then '-' 

5944 else to_char(round(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr)) 

5945 /(sum(street1Seen)+sum(street2Seen)+sum(street3Seen))),'90D0') 

5946 end AS PoFAFq 

5947 ,to_char(sum(totalProfit)/100.0,'9G999G990D00') AS Net 

5948 ,case when sum(n) = 0 then '0' 

5949 else to_char(sum(totalProfit/(gt.bigBlind+0.0)) / (sum(n)/100.0), '990D00') 

5950 end AS BBper100 

5951 ,case when sum(n) = 0 then '0' 

5952 else to_char( (sum(totalProfit)/100.0) / sum(n), '90D0000') 

5953 end AS Profitperhand 

5954 ,to_char(sum(seats*n)/(sum(n)+0.0),'90D00') AS AvgSeats 

5955 from Gametypes gt 

5956 inner join Sites s on (s.Id = gt.siteId) 

5957 inner join HudCache hc on (hc.gametypeId = gt.Id) 

5958 where hc.playerId in <player_test> 

5959 <gtbigBlind_test> 

5960 and hc.seats <seats_test> 

5961 and '20' || SUBSTR(hc.styleKey,2,2) || '-' || SUBSTR(hc.styleKey,4,2) || '-' 

5962 || SUBSTR(hc.styleKey,6,2) <datestest> 

5963 group by gt.base 

5964 ,gt.category 

5965 ,upper(gt.limitType) 

5966 ,s.name 

5967 <groupbygt.bigBlind> 

5968 ,gtId 

5969 <groupbyseats> 

5970 ,PlPosition 

5971 ) stats 

5972 inner join 

5973 ( select /* profit from handsplayers/handsactions */ 

5974 hprof.gtId, 

5975 case when hprof.position = 'B' then -2 

5976 when hprof.position = 'S' then -1 

5977 when hprof.position in ('3','4') then 2 

5978 when hprof.position in ('6','7') then 5 

5979 else cast(hprof.position as smallint) 

5980 end as PlPosition, 

5981 sum(hprof.profit) as sum_profit, 

5982 avg(hprof.profit/100.0) as profitperhand, 

5983 case when hprof.gtId = -1 then -999 

5984 else variance(hprof.profit/100.0) 

5985 end as variance 

5986 ,case when hprof.gtId = -1 then -999 

5987 else sqrt(variance(hprof.profit/100.0)) 

5988 end as stddev 

5989 from 

5990 (select hp.handId, <hgametypeId> as gtId, hp.position 

5991 , hp.totalProfit as profit 

5992 from HandsPlayers hp 

5993 inner join Hands h ON (h.id = hp.handId) 

5994 where hp.playerId in <player_test> 

5995 and hp.tourneysPlayersId IS NULL 

5996 and to_char(h.startTime, 'YYYY-MM-DD') <datestest> 

5997 group by hp.handId, gametypeId, hp.position, hp.totalProfit 

5998 ) hprof 

5999 group by hprof.gtId, PlPosition 

6000 ) hprof2 

6001 on ( hprof2.gtId = stats.gtId 

6002 and hprof2.PlPosition = stats.PlPosition) 

6003 order by stats.category, stats.limitType, stats.bigBlindDesc desc 

6004 <orderbyseats>, cast(stats.PlPosition as smallint) 

6005 """ 

6006 

6007 #################################### 

6008 # Cash Game Graph query 

6009 #################################### 

6010 self.query["getRingProfitAllHandsPlayerIdSite"] = """ 

6011 SELECT hp.handId, hp.totalProfit, hp.sawShowdown 

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 AND gt.type = 'ring' 

6023 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit 

6024 ORDER BY h.startTime""" 

6025 

6026 self.query["getRingProfitAllHandsPlayerIdSiteInBB"] = """ 

6027 SELECT hp.handId, ( hp.totalProfit / ( gt.bigBlind * 2.0 ) ) * 100 , hp.sawShowdown, ( hp.allInEV / ( gt.bigBlind * 2.0 ) ) * 100 

6028 FROM HandsPlayers hp 

6029 INNER JOIN Players pl ON (pl.id = hp.playerId) 

6030 INNER JOIN Hands h ON (h.id = hp.handId) 

6031 INNER JOIN Gametypes gt ON (gt.id = h.gametypeId) 

6032 WHERE pl.id in <player_test> 

6033 AND pl.siteId in <site_test> 

6034 AND h.startTime > '<startdate_test>' 

6035 AND h.startTime < '<enddate_test>' 

6036 <limit_test> 

6037 <game_test> 

6038 <currency_test> 

6039 AND hp.tourneysPlayersId IS NULL 

6040 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit, hp.allInEV, gt.bigBlind 

6041 ORDER BY h.startTime""" 

6042 

6043 self.query["getRingProfitAllHandsPlayerIdSiteInDollars"] = """ 

6044 SELECT hp.handId, hp.totalProfit, hp.sawShowdown, hp.allInEV 

6045 FROM HandsPlayers hp 

6046 INNER JOIN Players pl ON (pl.id = hp.playerId) 

6047 INNER JOIN Hands h ON (h.id = hp.handId) 

6048 INNER JOIN Gametypes gt ON (gt.id = h.gametypeId) 

6049 WHERE pl.id in <player_test> 

6050 AND pl.siteId in <site_test> 

6051 AND h.startTime > '<startdate_test>' 

6052 AND h.startTime < '<enddate_test>' 

6053 <limit_test> 

6054 <game_test> 

6055 <currency_test> 

6056 AND hp.tourneysPlayersId IS NULL 

6057 GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit, hp.allInEV 

6058 ORDER BY h.startTime""" 

6059 

6060 #################################### 

6061 # Tourney Results query 

6062 #################################### 

6063 self.query["tourneyResults"] = """ 

6064 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 

6065 FROM TourneysPlayers tp 

6066 INNER JOIN Players pl ON (pl.id = tp.playerId) 

6067 INNER JOIN Tourneys t ON (t.id = tp.tourneyId) 

6068 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId) 

6069 WHERE pl.id in <player_test> 

6070 AND pl.siteId in <site_test> 

6071 AND ((t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

6072 OR t.startTime is NULL) 

6073 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency, 

6074 tp.winnings, tp.koCount, 

6075 tp.rebuyCount, tp.addOnCount, 

6076 tt.buyIn, tt.fee, t.siteTourneyNo 

6077 ORDER BY t.startTime""" 

6078 

6079 # AND gt.type = 'ring' 

6080 # <limit_test> 

6081 # <game_test> 

6082 

6083 #################################### 

6084 # Tourney Graph query 

6085 # FIXME this is a horrible hack to prevent nonsense data 

6086 # being graphed - needs proper fix mantis #180 +#182 

6087 #################################### 

6088 self.query["tourneyGraph"] = """ 

6089 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 

6090 FROM TourneysPlayers tp 

6091 INNER JOIN Players pl ON (pl.id = tp.playerId) 

6092 INNER JOIN Tourneys t ON (t.id = tp.tourneyId) 

6093 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId) 

6094 WHERE pl.id in <player_test> 

6095 AND pl.siteId in <site_test> 

6096 AND (t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

6097 <currency_test> 

6098 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency, 

6099 tp.winnings, tp.koCount, 

6100 tp.rebuyCount, tp.addOnCount, 

6101 tt.buyIn, tt.fee, t.siteTourneyNo 

6102 ORDER BY t.startTime""" 

6103 

6104 # AND gt.type = 'ring' 

6105 # <limit_test> 

6106 # <game_test> 

6107 #################################### 

6108 # Tourney Graph query with tourneytypefilter 

6109 # FIXME this is a horrible hack to prevent nonsense data 

6110 # being graphed - needs proper fix mantis #180 +#182 

6111 #################################### 

6112 self.query["tourneyGraphType"] = """ 

6113 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 

6114 FROM TourneysPlayers tp 

6115 INNER JOIN Players pl ON (pl.id = tp.playerId) 

6116 INNER JOIN Tourneys t ON (t.id = tp.tourneyId) 

6117 INNER JOIN TourneyTypes tt ON (tt.id = t.tourneyTypeId) 

6118 WHERE pl.id in <player_test> 

6119 AND pl.siteId in <site_test> 

6120 AND tt.category in <tourney_cat> 

6121 AND tt.limitType in <tourney_lim> 

6122 AND tt.buyin in <tourney_buyin> 

6123 AND (t.startTime > '<startdate_test>' AND t.startTime < '<enddate_test>') 

6124 <currency_test> 

6125 GROUP BY t.startTime, tp.tourneyId, tp.winningsCurrency, 

6126 tp.winnings, tp.koCount, 

6127 tp.rebuyCount, tp.addOnCount, 

6128 tt.buyIn, tt.fee, t.siteTourneyNo 

6129 ORDER BY t.startTime""" 

6130 

6131 # AND gt.type = 'ring' 

6132 # <limit_test> 

6133 # <game_test> 

6134 

6135 #################################### 

6136 # Session stats query 

6137 #################################### 

6138 if db_server == "mysql": 

6139 self.query["sessionStats"] = """ 

6140 SELECT UNIX_TIMESTAMP(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 date_format(h.startTime, '%Y-%m-%d') <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 == "postgresql": 

6155 self.query["sessionStats"] = """ 

6156 SELECT EXTRACT(epoch from 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 LIKE 'ring' 

6165 <limit_test> 

6166 <game_test> 

6167 <seats_test> 

6168 <currency_test> 

6169 ORDER by time""" 

6170 elif db_server == "sqlite": 

6171 self.query["sessionStats"] = """ 

6172 SELECT STRFTIME('<ampersand_s>', h.startTime) as time, hp.totalProfit 

6173 FROM HandsPlayers hp 

6174 INNER JOIN Hands h on (h.id = hp.handId) 

6175 INNER JOIN Gametypes gt on (gt.Id = h.gametypeId) 

6176 INNER JOIN Sites s on (s.Id = gt.siteId) 

6177 INNER JOIN Players p on (p.Id = hp.playerId) 

6178 WHERE hp.playerId in <player_test> 

6179 AND h.startTime <datestest> 

6180 AND gt.type is 'ring' 

6181 <limit_test> 

6182 <game_test> 

6183 <seats_test> 

6184 <currency_test> 

6185 ORDER by time""" 

6186 

6187 #################################### 

6188 # Querry to get all hands in a date range 

6189 #################################### 

6190 self.query["handsInRange"] = """ 

6191 select h.id 

6192 from Hands h 

6193 join HandsPlayers hp on h.id = hp.handId 

6194 join Gametypes gt on gt.id = h.gametypeId 

6195 where h.startTime <datetest> 

6196 and hp.playerId in <player_test> 

6197 <game_test> 

6198 <limit_test> 

6199 <position_test>""" 

6200 

6201 #################################### 

6202 # Querry to get all hands in a date range for cash games session 

6203 #################################### 

6204 self.query["handsInRangeSession"] = """ 

6205 select h.id 

6206 from Hands h 

6207  

6208 where h.startTime <datetest> 

6209 """ 

6210 

6211 #################################### 

6212 # Querry to get all hands in a date range for cash games session variation filter 

6213 #################################### 

6214 self.query["handsInRangeSessionFilter"] = """ 

6215 select h.id 

6216 from Hands h 

6217 join Gametypes gt on h.gametypeId = gt.id 

6218 join HandsPlayers hp on h.id = hp.handId -- utilisation de HandsPlayers 

6219 where h.startTime <datetest> 

6220 <game_test> 

6221 <limit_test> 

6222 <player_test> 

6223 <position_test> 

6224 """ 

6225 

6226 self.query["getPlayerId"] = """ 

6227 SELECT id  

6228 FROM Players  

6229 WHERE siteId = %s  

6230 AND name = %s 

6231 """ 

6232 

6233 #################################### 

6234 # Query to get a single hand for the replayer 

6235 #################################### 

6236 self.query["singleHand"] = """ 

6237 SELECT h.* 

6238 FROM Hands h 

6239 WHERE id = %s""" 

6240 

6241 #################################### 

6242 # Query to get run it twice boards for the replayer 

6243 #################################### 

6244 self.query["singleHandBoards"] = """ 

6245 SELECT b.* 

6246 FROM Boards b 

6247 WHERE handId = %s""" 

6248 

6249 #################################### 

6250 # Query to get a single player hand for the replayer 

6251 #################################### 

6252 self.query["playerHand"] = """ 

6253 SELECT 

6254 hp.seatno, 

6255 round(hp.winnings / 100.0,2) as winnings, 

6256 p.name, 

6257 round(hp.startCash / 100.0,2) as chips, 

6258 hp.card1,hp.card2,hp.card3,hp.card4,hp.card5, 

6259 hp.card6,hp.card7,hp.card8,hp.card9,hp.card10, 

6260 hp.card11,hp.card12,hp.card13,hp.card14,hp.card15, 

6261 hp.card16,hp.card17,hp.card18,hp.card19,hp.card20, 

6262 hp.position, 

6263 round(hp.startBounty / 100.0,2) as bounty, 

6264 hp.sitout 

6265 FROM 

6266 HandsPlayers as hp, 

6267 Players as p 

6268 WHERE 

6269 hp.handId = %s 

6270 and p.id = hp.playerId 

6271 ORDER BY 

6272 hp.seatno 

6273 """ 

6274 

6275 #################################### 

6276 # Query for the actions of a hand 

6277 #################################### 

6278 self.query["handActions"] = """ 

6279 SELECT 

6280 ha.actionNo, 

6281 p.name, 

6282 ha.street, 

6283 ha.actionId, 

6284 ha.allIn, 

6285 round(ha.amount / 100.0,2) as bet, 

6286 ha.numDiscarded, 

6287 ha.cardsDiscarded 

6288 FROM 

6289 HandsActions as ha, 

6290 Players as p, 

6291 Hands as h 

6292 WHERE 

6293 h.id = %s 

6294 AND ha.handId = h.id 

6295 AND ha.playerId = p.id 

6296 ORDER BY 

6297 ha.id ASC 

6298 """ 

6299 

6300 #################################### 

6301 # Queries to rebuild/modify hudcache 

6302 #################################### 

6303 

6304 self.query["clearHudCache"] = """DELETE FROM HudCache""" 

6305 self.query["clearCardsCache"] = """DELETE FROM CardsCache""" 

6306 self.query["clearPositionsCache"] = """DELETE FROM PositionsCache""" 

6307 

6308 self.query["clearHudCacheTourneyType"] = """DELETE FROM HudCache WHERE tourneyTypeId = %s""" 

6309 self.query["clearCardsCacheTourneyType"] = """DELETE FROM CardsCache WHERE tourneyTypeId = %s""" 

6310 self.query["clearPositionsCacheTourneyType"] = """DELETE FROM PositionsCache WHERE tourneyTypeId = %s""" 

6311 

6312 self.query["fetchNewHudCacheTourneyTypeIds"] = """SELECT TT.id 

6313 FROM TourneyTypes TT 

6314 LEFT OUTER JOIN HudCache HC ON (TT.id = HC.tourneyTypeId) 

6315 WHERE HC.tourneyTypeId is NULL 

6316 """ 

6317 

6318 self.query["fetchNewCardsCacheTourneyTypeIds"] = """SELECT TT.id 

6319 FROM TourneyTypes TT 

6320 LEFT OUTER JOIN CardsCache CC ON (TT.id = CC.tourneyTypeId) 

6321 WHERE CC.tourneyTypeId is NULL 

6322 """ 

6323 

6324 self.query["fetchNewPositionsCacheTourneyTypeIds"] = """SELECT TT.id 

6325 FROM TourneyTypes TT 

6326 LEFT OUTER JOIN PositionsCache PC ON (TT.id = PC.tourneyTypeId) 

6327 WHERE PC.tourneyTypeId is NULL 

6328 """ 

6329 

6330 self.query["clearCardsCacheWeeksMonths"] = """DELETE FROM CardsCache WHERE weekId = %s AND monthId = %s""" 

6331 self.query["clearPositionsCacheWeeksMonths"] = ( 

6332 """DELETE FROM PositionsCache WHERE weekId = %s AND monthId = %s""" 

6333 ) 

6334 

6335 self.query["selectSessionWithWeekId"] = """SELECT id FROM Sessions WHERE weekId = %s""" 

6336 self.query["selectSessionWithMonthId"] = """SELECT id FROM Sessions WHERE monthId = %s""" 

6337 

6338 self.query["deleteWeekId"] = """DELETE FROM Weeks WHERE id = %s""" 

6339 self.query["deleteMonthId"] = """DELETE FROM Months WHERE id = %s""" 

6340 

6341 self.query["fetchNewCardsCacheWeeksMonths"] = """SELECT SCG.weekId, SCG.monthId 

6342 FROM (SELECT DISTINCT weekId, monthId FROM Sessions) SCG 

6343 LEFT OUTER JOIN CardsCache CC ON (SCG.weekId = CC.weekId AND SCG.monthId = CC.monthId) 

6344 WHERE CC.weekId is NULL OR CC.monthId is NULL 

6345 """ 

6346 

6347 self.query["fetchNewPositionsCacheWeeksMonths"] = """SELECT SCG.weekId, SCG.monthId 

6348 FROM (SELECT DISTINCT weekId, monthId FROM Sessions) SCG 

6349 LEFT OUTER JOIN PositionsCache PC ON (SCG.weekId = PC.weekId AND SCG.monthId = PC.monthId) 

6350 WHERE PC.weekId is NULL OR PC.monthId is NULL 

6351 """ 

6352 

6353 if db_server == "mysql": 

6354 self.query["rebuildCache"] = """insert into <insert> 

6355 ,n 

6356 ,street0VPIChance 

6357 ,street0VPI 

6358 ,street0AggrChance 

6359 ,street0Aggr 

6360 ,street0CalledRaiseChance 

6361 ,street0CalledRaiseDone 

6362 ,street0_2BChance 

6363 ,street0_2BDone 

6364 ,street0_3BChance 

6365 ,street0_3BDone 

6366 ,street0_4BChance 

6367 ,street0_4BDone 

6368 ,street0_C4BChance 

6369 ,street0_C4BDone 

6370 ,street0_FoldTo2BChance 

6371 ,street0_FoldTo2BDone 

6372 ,street0_FoldTo3BChance 

6373 ,street0_FoldTo3BDone 

6374 ,street0_FoldTo4BChance 

6375 ,street0_FoldTo4BDone 

6376 ,street0_SqueezeChance 

6377 ,street0_SqueezeDone 

6378 ,raiseToStealChance 

6379 ,raiseToStealDone 

6380 ,stealChance 

6381 ,stealDone 

6382 ,success_Steal 

6383 ,street1Seen 

6384 ,street2Seen 

6385 ,street3Seen 

6386 ,street4Seen 

6387 ,sawShowdown 

6388 ,street1Aggr 

6389 ,street2Aggr 

6390 ,street3Aggr 

6391 ,street4Aggr 

6392 ,otherRaisedStreet0 

6393 ,otherRaisedStreet1 

6394 ,otherRaisedStreet2 

6395 ,otherRaisedStreet3 

6396 ,otherRaisedStreet4 

6397 ,foldToOtherRaisedStreet0 

6398 ,foldToOtherRaisedStreet1 

6399 ,foldToOtherRaisedStreet2 

6400 ,foldToOtherRaisedStreet3 

6401 ,foldToOtherRaisedStreet4 

6402 ,wonWhenSeenStreet1 

6403 ,wonWhenSeenStreet2 

6404 ,wonWhenSeenStreet3 

6405 ,wonWhenSeenStreet4 

6406 ,wonAtSD 

6407 ,raiseFirstInChance 

6408 ,raisedFirstIn 

6409 ,foldBbToStealChance 

6410 ,foldedBbToSteal 

6411 ,foldSbToStealChance 

6412 ,foldedSbToSteal 

6413 ,street1CBChance 

6414 ,street1CBDone 

6415 ,street2CBChance 

6416 ,street2CBDone 

6417 ,street3CBChance 

6418 ,street3CBDone 

6419 ,street4CBChance 

6420 ,street4CBDone 

6421 ,foldToStreet1CBChance 

6422 ,foldToStreet1CBDone 

6423 ,foldToStreet2CBChance 

6424 ,foldToStreet2CBDone 

6425 ,foldToStreet3CBChance 

6426 ,foldToStreet3CBDone 

6427 ,foldToStreet4CBChance 

6428 ,foldToStreet4CBDone 

6429 ,common 

6430 ,committed 

6431 ,winnings 

6432 ,rake 

6433 ,rakeDealt 

6434 ,rakeContributed 

6435 ,rakeWeighted 

6436 ,totalProfit 

6437 ,allInEV 

6438 ,showdownWinnings 

6439 ,nonShowdownWinnings 

6440 ,street1CheckCallRaiseChance 

6441 ,street1CheckCallDone 

6442 ,street1CheckRaiseDone 

6443 ,street2CheckCallRaiseChance 

6444 ,street2CheckCallDone 

6445 ,street2CheckRaiseDone 

6446 ,street3CheckCallRaiseChance 

6447 ,street3CheckCallDone 

6448 ,street3CheckRaiseDone 

6449 ,street4CheckCallRaiseChance 

6450 ,street4CheckCallDone 

6451 ,street4CheckRaiseDone 

6452 ,street0Calls 

6453 ,street1Calls 

6454 ,street2Calls 

6455 ,street3Calls 

6456 ,street4Calls 

6457 ,street0Bets 

6458 ,street1Bets 

6459 ,street2Bets 

6460 ,street3Bets 

6461 ,street4Bets 

6462 ,street0Raises 

6463 ,street1Raises 

6464 ,street2Raises 

6465 ,street3Raises 

6466 ,street4Raises 

6467 ,street1Discards 

6468 ,street2Discards 

6469 ,street3Discards 

6470 ) 

6471 SELECT <select> 

6472 ,count(1) 

6473 ,sum(street0VPIChance) 

6474 ,sum(street0VPI) 

6475 ,sum(street0AggrChance) 

6476 ,sum(street0Aggr) 

6477 ,sum(street0CalledRaiseChance) 

6478 ,sum(street0CalledRaiseDone) 

6479 ,sum(street0_2BChance) 

6480 ,sum(street0_2BDone) 

6481 ,sum(street0_3BChance) 

6482 ,sum(street0_3BDone) 

6483 ,sum(street0_4BChance) 

6484 ,sum(street0_4BDone) 

6485 ,sum(street0_C4BChance) 

6486 ,sum(street0_C4BDone) 

6487 ,sum(street0_FoldTo2BChance) 

6488 ,sum(street0_FoldTo2BDone) 

6489 ,sum(street0_FoldTo3BChance) 

6490 ,sum(street0_FoldTo3BDone) 

6491 ,sum(street0_FoldTo4BChance) 

6492 ,sum(street0_FoldTo4BDone) 

6493 ,sum(street0_SqueezeChance) 

6494 ,sum(street0_SqueezeDone) 

6495 ,sum(raiseToStealChance) 

6496 ,sum(raiseToStealDone) 

6497 ,sum(stealChance) 

6498 ,sum(stealDone) 

6499 ,sum(success_Steal) 

6500 ,sum(street1Seen) 

6501 ,sum(street2Seen) 

6502 ,sum(street3Seen) 

6503 ,sum(street4Seen) 

6504 ,sum(sawShowdown) 

6505 ,sum(street1Aggr) 

6506 ,sum(street2Aggr) 

6507 ,sum(street3Aggr) 

6508 ,sum(street4Aggr) 

6509 ,sum(otherRaisedStreet0) 

6510 ,sum(otherRaisedStreet1) 

6511 ,sum(otherRaisedStreet2) 

6512 ,sum(otherRaisedStreet3) 

6513 ,sum(otherRaisedStreet4) 

6514 ,sum(foldToOtherRaisedStreet0) 

6515 ,sum(foldToOtherRaisedStreet1) 

6516 ,sum(foldToOtherRaisedStreet2) 

6517 ,sum(foldToOtherRaisedStreet3) 

6518 ,sum(foldToOtherRaisedStreet4) 

6519 ,sum(wonWhenSeenStreet1) 

6520 ,sum(wonWhenSeenStreet2) 

6521 ,sum(wonWhenSeenStreet3) 

6522 ,sum(wonWhenSeenStreet4) 

6523 ,sum(wonAtSD) 

6524 ,sum(raiseFirstInChance) 

6525 ,sum(raisedFirstIn) 

6526 ,sum(foldBbToStealChance) 

6527 ,sum(foldedBbToSteal) 

6528 ,sum(foldSbToStealChance) 

6529 ,sum(foldedSbToSteal) 

6530 ,sum(street1CBChance) 

6531 ,sum(street1CBDone) 

6532 ,sum(street2CBChance) 

6533 ,sum(street2CBDone) 

6534 ,sum(street3CBChance) 

6535 ,sum(street3CBDone) 

6536 ,sum(street4CBChance) 

6537 ,sum(street4CBDone) 

6538 ,sum(foldToStreet1CBChance) 

6539 ,sum(foldToStreet1CBDone) 

6540 ,sum(foldToStreet2CBChance) 

6541 ,sum(foldToStreet2CBDone) 

6542 ,sum(foldToStreet3CBChance) 

6543 ,sum(foldToStreet3CBDone) 

6544 ,sum(foldToStreet4CBChance) 

6545 ,sum(foldToStreet4CBDone) 

6546 ,sum(common) 

6547 ,sum(committed) 

6548 ,sum(winnings) 

6549 ,sum(rake) 

6550 ,sum(rakeDealt) 

6551 ,sum(rakeContributed) 

6552 ,sum(rakeWeighted) 

6553 ,sum(totalProfit) 

6554 ,sum(allInEV) 

6555 ,sum(case when sawShowdown = 1 then totalProfit else 0 end) 

6556 ,sum(case when sawShowdown = 0 then totalProfit else 0 end) 

6557 ,sum(street1CheckCallRaiseChance) 

6558 ,sum(street1CheckCallDone) 

6559 ,sum(street1CheckRaiseDone) 

6560 ,sum(street2CheckCallRaiseChance) 

6561 ,sum(street2CheckCallDone) 

6562 ,sum(street2CheckRaiseDone) 

6563 ,sum(street3CheckCallRaiseChance) 

6564 ,sum(street3CheckCallDone) 

6565 ,sum(street3CheckRaiseDone) 

6566 ,sum(street4CheckCallRaiseChance) 

6567 ,sum(street4CheckCallDone) 

6568 ,sum(street4CheckRaiseDone) 

6569 ,sum(street0Calls) 

6570 ,sum(street1Calls) 

6571 ,sum(street2Calls) 

6572 ,sum(street3Calls) 

6573 ,sum(street4Calls) 

6574 ,sum(street0Bets) 

6575 ,sum(street1Bets) 

6576 ,sum(street2Bets) 

6577 ,sum(street3Bets) 

6578 ,sum(street4Bets) 

6579 ,sum(hp.street0Raises) 

6580 ,sum(hp.street1Raises) 

6581 ,sum(hp.street2Raises) 

6582 ,sum(hp.street3Raises) 

6583 ,sum(hp.street4Raises) 

6584 ,sum(street1Discards) 

6585 ,sum(street2Discards) 

6586 ,sum(street3Discards) 

6587 FROM Hands h 

6588 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>) 

6589 INNER JOIN Gametypes g ON (h.gametypeId = g.id) 

6590 <sessions_join_clause> 

6591 <tourney_join_clause> 

6592 <where_clause> 

6593 GROUP BY <group> 

6594""" 

6595 elif db_server == "postgresql": 

6596 self.query["rebuildCache"] = """insert into <insert> 

6597 ,n 

6598 ,street0VPIChance 

6599 ,street0VPI 

6600 ,street0AggrChance 

6601 ,street0Aggr 

6602 ,street0CalledRaiseChance 

6603 ,street0CalledRaiseDone 

6604 ,street0_2BChance 

6605 ,street0_2BDone 

6606 ,street0_3BChance 

6607 ,street0_3BDone 

6608 ,street0_4BChance 

6609 ,street0_4BDone 

6610 ,street0_C4BChance 

6611 ,street0_C4BDone 

6612 ,street0_FoldTo2BChance 

6613 ,street0_FoldTo2BDone 

6614 ,street0_FoldTo3BChance 

6615 ,street0_FoldTo3BDone 

6616 ,street0_FoldTo4BChance 

6617 ,street0_FoldTo4BDone 

6618 ,street0_SqueezeChance 

6619 ,street0_SqueezeDone 

6620 ,raiseToStealChance 

6621 ,raiseToStealDone 

6622 ,stealChance 

6623 ,stealDone 

6624 ,success_Steal 

6625 ,street1Seen 

6626 ,street2Seen 

6627 ,street3Seen 

6628 ,street4Seen 

6629 ,sawShowdown 

6630 ,street1Aggr 

6631 ,street2Aggr 

6632 ,street3Aggr 

6633 ,street4Aggr 

6634 ,otherRaisedStreet0 

6635 ,otherRaisedStreet1 

6636 ,otherRaisedStreet2 

6637 ,otherRaisedStreet3 

6638 ,otherRaisedStreet4 

6639 ,foldToOtherRaisedStreet0 

6640 ,foldToOtherRaisedStreet1 

6641 ,foldToOtherRaisedStreet2 

6642 ,foldToOtherRaisedStreet3 

6643 ,foldToOtherRaisedStreet4  

6644 ,wonWhenSeenStreet1 

6645 ,wonWhenSeenStreet2 

6646 ,wonWhenSeenStreet3 

6647 ,wonWhenSeenStreet4 

6648 ,wonAtSD 

6649 ,raiseFirstInChance 

6650 ,raisedFirstIn 

6651 ,foldBbToStealChance 

6652 ,foldedBbToSteal 

6653 ,foldSbToStealChance 

6654 ,foldedSbToSteal 

6655 ,street1CBChance 

6656 ,street1CBDone 

6657 ,street2CBChance 

6658 ,street2CBDone 

6659 ,street3CBChance 

6660 ,street3CBDone 

6661 ,street4CBChance 

6662 ,street4CBDone 

6663 ,foldToStreet1CBChance 

6664 ,foldToStreet1CBDone 

6665 ,foldToStreet2CBChance 

6666 ,foldToStreet2CBDone 

6667 ,foldToStreet3CBChance 

6668 ,foldToStreet3CBDone 

6669 ,foldToStreet4CBChance 

6670 ,foldToStreet4CBDone 

6671 ,common 

6672 ,committed 

6673 ,winnings 

6674 ,rake 

6675 ,rakeDealt 

6676 ,rakeContributed 

6677 ,rakeWeighted 

6678 ,totalProfit 

6679 ,allInEV 

6680 ,showdownWinnings 

6681 ,nonShowdownWinnings 

6682 ,street1CheckCallRaiseChance 

6683 ,street1CheckCallDone 

6684 ,street1CheckRaiseDone 

6685 ,street2CheckCallRaiseChance 

6686 ,street2CheckCallDone 

6687 ,street2CheckRaiseDone 

6688 ,street3CheckCallRaiseChance 

6689 ,street3CheckCallDone 

6690 ,street3CheckRaiseDone 

6691 ,street4CheckCallRaiseChance 

6692 ,street4CheckCallDone 

6693 ,street4CheckRaiseDone 

6694 ,street0Calls 

6695 ,street1Calls 

6696 ,street2Calls 

6697 ,street3Calls 

6698 ,street4Calls 

6699 ,street0Bets 

6700 ,street1Bets 

6701 ,street2Bets 

6702 ,street3Bets 

6703 ,street4Bets 

6704 ,street0Raises 

6705 ,street1Raises 

6706 ,street2Raises 

6707 ,street3Raises 

6708 ,street4Raises 

6709 ,street1Discards 

6710 ,street2Discards 

6711 ,street3Discards 

6712 ) 

6713 SELECT <select> 

6714 ,count(1) 

6715 ,sum(CAST(street0VPIChance as integer)) 

6716 ,sum(CAST(street0VPI as integer)) 

6717 ,sum(CAST(street0AggrChance as integer)) 

6718 ,sum(CAST(street0Aggr as integer)) 

6719 ,sum(CAST(street0CalledRaiseChance as integer)) 

6720 ,sum(CAST(street0CalledRaiseDone as integer)) 

6721 ,sum(CAST(street0_2BChance as integer)) 

6722 ,sum(CAST(street0_2BDone as integer)) 

6723 ,sum(CAST(street0_3BChance as integer)) 

6724 ,sum(CAST(street0_3BDone as integer)) 

6725 ,sum(CAST(street0_4BChance as integer)) 

6726 ,sum(CAST(street0_4BDone as integer)) 

6727 ,sum(CAST(street0_C4BChance as integer)) 

6728 ,sum(CAST(street0_C4BDone as integer)) 

6729 ,sum(CAST(street0_FoldTo2BChance as integer)) 

6730 ,sum(CAST(street0_FoldTo2BDone as integer)) 

6731 ,sum(CAST(street0_FoldTo3BChance as integer)) 

6732 ,sum(CAST(street0_FoldTo3BDone as integer)) 

6733 ,sum(CAST(street0_FoldTo4BChance as integer)) 

6734 ,sum(CAST(street0_FoldTo4BDone as integer)) 

6735 ,sum(CAST(street0_SqueezeChance as integer)) 

6736 ,sum(CAST(street0_SqueezeDone as integer)) 

6737 ,sum(CAST(raiseToStealChance as integer)) 

6738 ,sum(CAST(raiseToStealDone as integer)) 

6739 ,sum(CAST(stealChance as integer)) 

6740 ,sum(CAST(stealDone as integer)) 

6741 ,sum(CAST(success_Steal as integer)) 

6742 ,sum(CAST(street1Seen as integer)) 

6743 ,sum(CAST(street2Seen as integer)) 

6744 ,sum(CAST(street3Seen as integer)) 

6745 ,sum(CAST(street4Seen as integer)) 

6746 ,sum(CAST(sawShowdown as integer)) 

6747 ,sum(CAST(street1Aggr as integer)) 

6748 ,sum(CAST(street2Aggr as integer)) 

6749 ,sum(CAST(street3Aggr as integer)) 

6750 ,sum(CAST(street4Aggr as integer)) 

6751 ,sum(CAST(otherRaisedStreet0 as integer)) 

6752 ,sum(CAST(otherRaisedStreet1 as integer)) 

6753 ,sum(CAST(otherRaisedStreet2 as integer)) 

6754 ,sum(CAST(otherRaisedStreet3 as integer)) 

6755 ,sum(CAST(otherRaisedStreet4 as integer)) 

6756 ,sum(CAST(foldToOtherRaisedStreet0 as integer)) 

6757 ,sum(CAST(foldToOtherRaisedStreet1 as integer)) 

6758 ,sum(CAST(foldToOtherRaisedStreet2 as integer)) 

6759 ,sum(CAST(foldToOtherRaisedStreet3 as integer)) 

6760 ,sum(CAST(foldToOtherRaisedStreet4 as integer))  

6761 ,sum(CAST(wonWhenSeenStreet1 as integer)) 

6762 ,sum(CAST(wonWhenSeenStreet2 as integer)) 

6763 ,sum(CAST(wonWhenSeenStreet3 as integer)) 

6764 ,sum(CAST(wonWhenSeenStreet4 as integer)) 

6765 ,sum(CAST(wonAtSD as integer)) 

6766 ,sum(CAST(raiseFirstInChance as integer)) 

6767 ,sum(CAST(raisedFirstIn as integer)) 

6768 ,sum(CAST(foldBbToStealChance as integer)) 

6769 ,sum(CAST(foldedBbToSteal as integer)) 

6770 ,sum(CAST(foldSbToStealChance as integer)) 

6771 ,sum(CAST(foldedSbToSteal as integer)) 

6772 ,sum(CAST(street1CBChance as integer)) 

6773 ,sum(CAST(street1CBDone as integer)) 

6774 ,sum(CAST(street2CBChance as integer)) 

6775 ,sum(CAST(street2CBDone as integer)) 

6776 ,sum(CAST(street3CBChance as integer)) 

6777 ,sum(CAST(street3CBDone as integer)) 

6778 ,sum(CAST(street4CBChance as integer)) 

6779 ,sum(CAST(street4CBDone as integer)) 

6780 ,sum(CAST(foldToStreet1CBChance as integer)) 

6781 ,sum(CAST(foldToStreet1CBDone as integer)) 

6782 ,sum(CAST(foldToStreet2CBChance as integer)) 

6783 ,sum(CAST(foldToStreet2CBDone as integer)) 

6784 ,sum(CAST(foldToStreet3CBChance as integer)) 

6785 ,sum(CAST(foldToStreet3CBDone as integer)) 

6786 ,sum(CAST(foldToStreet4CBChance as integer)) 

6787 ,sum(CAST(foldToStreet4CBDone as integer)) 

6788 ,sum(common) 

6789 ,sum(committed) 

6790 ,sum(winnings) 

6791 ,sum(rake) 

6792 ,sum(rakeDealt) 

6793 ,sum(rakeContributed) 

6794 ,sum(rakeWeighted) 

6795 ,sum(totalProfit) 

6796 ,sum(allInEV) 

6797 ,sum(case when sawShowdown then totalProfit else 0 end) 

6798 ,sum(case when sawShowdown then 0 else totalProfit end) 

6799 ,sum(CAST(street1CheckCallRaiseChance as integer)) 

6800 ,sum(CAST(street1CheckCallDone as integer)) 

6801 ,sum(CAST(street1CheckRaiseDone as integer)) 

6802 ,sum(CAST(street2CheckCallRaiseChance as integer)) 

6803 ,sum(CAST(street2CheckCallDone as integer)) 

6804 ,sum(CAST(street2CheckRaiseDone as integer)) 

6805 ,sum(CAST(street3CheckCallRaiseChance as integer)) 

6806 ,sum(CAST(street3CheckCallDone as integer)) 

6807 ,sum(CAST(street3CheckRaiseDone as integer)) 

6808 ,sum(CAST(street4CheckCallRaiseChance as integer)) 

6809 ,sum(CAST(street4CheckCallDone as integer)) 

6810 ,sum(CAST(street4CheckRaiseDone as integer)) 

6811 ,sum(CAST(street0Calls as integer)) 

6812 ,sum(CAST(street1Calls as integer)) 

6813 ,sum(CAST(street2Calls as integer)) 

6814 ,sum(CAST(street3Calls as integer)) 

6815 ,sum(CAST(street4Calls as integer)) 

6816 ,sum(CAST(street0Bets as integer)) 

6817 ,sum(CAST(street1Bets as integer)) 

6818 ,sum(CAST(street2Bets as integer)) 

6819 ,sum(CAST(street3Bets as integer)) 

6820 ,sum(CAST(street4Bets as integer)) 

6821 ,sum(CAST(hp.street0Raises as integer)) 

6822 ,sum(CAST(hp.street1Raises as integer)) 

6823 ,sum(CAST(hp.street2Raises as integer)) 

6824 ,sum(CAST(hp.street3Raises as integer)) 

6825 ,sum(CAST(hp.street4Raises as integer)) 

6826 ,sum(CAST(street1Discards as integer)) 

6827 ,sum(CAST(street2Discards as integer)) 

6828 ,sum(CAST(street3Discards as integer)) 

6829 FROM Hands h 

6830 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>) 

6831 INNER JOIN Gametypes g ON (h.gametypeId = g.id) 

6832 <sessions_join_clause> 

6833 <tourney_join_clause> 

6834 <where_clause> 

6835 GROUP BY <group> 

6836""" 

6837 elif db_server == "sqlite": 

6838 self.query["rebuildCache"] = """insert into <insert> 

6839 ,n 

6840 ,street0VPIChance 

6841 ,street0VPI 

6842 ,street0AggrChance 

6843 ,street0Aggr 

6844 ,street0CalledRaiseChance 

6845 ,street0CalledRaiseDone 

6846 ,street0_2BChance 

6847 ,street0_2BDone 

6848 ,street0_3BChance 

6849 ,street0_3BDone 

6850 ,street0_4BChance 

6851 ,street0_4BDone 

6852 ,street0_C4BChance 

6853 ,street0_C4BDone 

6854 ,street0_FoldTo2BChance 

6855 ,street0_FoldTo2BDone 

6856 ,street0_FoldTo3BChance 

6857 ,street0_FoldTo3BDone 

6858 ,street0_FoldTo4BChance 

6859 ,street0_FoldTo4BDone 

6860 ,street0_SqueezeChance 

6861 ,street0_SqueezeDone 

6862 ,raiseToStealChance 

6863 ,raiseToStealDone 

6864 ,stealChance 

6865 ,stealDone 

6866 ,success_Steal 

6867 ,street1Seen 

6868 ,street2Seen 

6869 ,street3Seen 

6870 ,street4Seen 

6871 ,sawShowdown 

6872 ,street1Aggr 

6873 ,street2Aggr 

6874 ,street3Aggr 

6875 ,street4Aggr 

6876 ,otherRaisedStreet0 

6877 ,otherRaisedStreet1 

6878 ,otherRaisedStreet2 

6879 ,otherRaisedStreet3 

6880 ,otherRaisedStreet4 

6881 ,foldToOtherRaisedStreet0 

6882 ,foldToOtherRaisedStreet1 

6883 ,foldToOtherRaisedStreet2 

6884 ,foldToOtherRaisedStreet3 

6885 ,foldToOtherRaisedStreet4 

6886 ,wonWhenSeenStreet1 

6887 ,wonWhenSeenStreet2 

6888 ,wonWhenSeenStreet3 

6889 ,wonWhenSeenStreet4 

6890 ,wonAtSD 

6891 ,raiseFirstInChance 

6892 ,raisedFirstIn 

6893 ,foldBbToStealChance 

6894 ,foldedBbToSteal 

6895 ,foldSbToStealChance 

6896 ,foldedSbToSteal 

6897 ,street1CBChance 

6898 ,street1CBDone 

6899 ,street2CBChance 

6900 ,street2CBDone 

6901 ,street3CBChance 

6902 ,street3CBDone 

6903 ,street4CBChance 

6904 ,street4CBDone 

6905 ,foldToStreet1CBChance 

6906 ,foldToStreet1CBDone 

6907 ,foldToStreet2CBChance 

6908 ,foldToStreet2CBDone 

6909 ,foldToStreet3CBChance 

6910 ,foldToStreet3CBDone 

6911 ,foldToStreet4CBChance 

6912 ,foldToStreet4CBDone 

6913 ,common 

6914 ,committed 

6915 ,winnings 

6916 ,rake 

6917 ,rakeDealt 

6918 ,rakeContributed 

6919 ,rakeWeighted 

6920 ,totalProfit 

6921 ,allInEV 

6922 ,showdownWinnings 

6923 ,nonShowdownWinnings 

6924 ,street1CheckCallRaiseChance 

6925 ,street1CheckCallDone 

6926 ,street1CheckRaiseDone 

6927 ,street2CheckCallRaiseChance 

6928 ,street2CheckCallDone 

6929 ,street2CheckRaiseDone 

6930 ,street3CheckCallRaiseChance 

6931 ,street3CheckCallDone 

6932 ,street3CheckRaiseDone 

6933 ,street4CheckCallRaiseChance 

6934 ,street4CheckCallDone 

6935 ,street4CheckRaiseDone 

6936 ,street0Calls 

6937 ,street1Calls 

6938 ,street2Calls 

6939 ,street3Calls 

6940 ,street4Calls 

6941 ,street0Bets 

6942 ,street1Bets 

6943 ,street2Bets 

6944 ,street3Bets 

6945 ,street4Bets 

6946 ,street0Raises 

6947 ,street1Raises 

6948 ,street2Raises 

6949 ,street3Raises 

6950 ,street4Raises 

6951 ,street1Discards 

6952 ,street2Discards 

6953 ,street3Discards 

6954 ) 

6955 SELECT <select> 

6956 ,count(1) 

6957 ,sum(CAST(street0VPIChance as integer)) 

6958 ,sum(CAST(street0VPI as integer)) 

6959 ,sum(CAST(street0AggrChance as integer)) 

6960 ,sum(CAST(street0Aggr as integer)) 

6961 ,sum(CAST(street0CalledRaiseChance as integer)) 

6962 ,sum(CAST(street0CalledRaiseDone as integer)) 

6963 ,sum(CAST(street0_2BChance as integer)) 

6964 ,sum(CAST(street0_2BDone as integer)) 

6965 ,sum(CAST(street0_3BChance as integer)) 

6966 ,sum(CAST(street0_3BDone as integer)) 

6967 ,sum(CAST(street0_4BChance as integer)) 

6968 ,sum(CAST(street0_4BDone as integer)) 

6969 ,sum(CAST(street0_C4BChance as integer)) 

6970 ,sum(CAST(street0_C4BDone as integer)) 

6971 ,sum(CAST(street0_FoldTo2BChance as integer)) 

6972 ,sum(CAST(street0_FoldTo2BDone as integer)) 

6973 ,sum(CAST(street0_FoldTo3BChance as integer)) 

6974 ,sum(CAST(street0_FoldTo3BDone as integer)) 

6975 ,sum(CAST(street0_FoldTo4BChance as integer)) 

6976 ,sum(CAST(street0_FoldTo4BDone as integer)) 

6977 ,sum(CAST(street0_SqueezeChance as integer)) 

6978 ,sum(CAST(street0_SqueezeDone as integer)) 

6979 ,sum(CAST(raiseToStealChance as integer)) 

6980 ,sum(CAST(raiseToStealDone as integer)) 

6981 ,sum(CAST(stealChance as integer)) 

6982 ,sum(CAST(stealDone as integer)) 

6983 ,sum(CAST(success_Steal as integer)) 

6984 ,sum(CAST(street1Seen as integer)) 

6985 ,sum(CAST(street2Seen as integer)) 

6986 ,sum(CAST(street3Seen as integer)) 

6987 ,sum(CAST(street4Seen as integer)) 

6988 ,sum(CAST(sawShowdown as integer)) 

6989 ,sum(CAST(street1Aggr as integer)) 

6990 ,sum(CAST(street2Aggr as integer)) 

6991 ,sum(CAST(street3Aggr as integer)) 

6992 ,sum(CAST(street4Aggr as integer)) 

6993 ,sum(CAST(otherRaisedStreet0 as integer)) 

6994 ,sum(CAST(otherRaisedStreet1 as integer)) 

6995 ,sum(CAST(otherRaisedStreet2 as integer)) 

6996 ,sum(CAST(otherRaisedStreet3 as integer)) 

6997 ,sum(CAST(otherRaisedStreet4 as integer)) 

6998 ,sum(CAST(foldToOtherRaisedStreet0 as integer)) 

6999 ,sum(CAST(foldToOtherRaisedStreet1 as integer)) 

7000 ,sum(CAST(foldToOtherRaisedStreet2 as integer)) 

7001 ,sum(CAST(foldToOtherRaisedStreet3 as integer)) 

7002 ,sum(CAST(foldToOtherRaisedStreet4 as integer)) 

7003 ,sum(CAST(wonWhenSeenStreet1 as integer)) 

7004 ,sum(CAST(wonWhenSeenStreet2 as integer)) 

7005 ,sum(CAST(wonWhenSeenStreet3 as integer)) 

7006 ,sum(CAST(wonWhenSeenStreet4 as integer)) 

7007 ,sum(CAST(wonAtSD as integer)) 

7008 ,sum(CAST(raiseFirstInChance as integer)) 

7009 ,sum(CAST(raisedFirstIn as integer)) 

7010 ,sum(CAST(foldBbToStealChance as integer)) 

7011 ,sum(CAST(foldedBbToSteal as integer)) 

7012 ,sum(CAST(foldSbToStealChance as integer)) 

7013 ,sum(CAST(foldedSbToSteal as integer)) 

7014 ,sum(CAST(street1CBChance as integer)) 

7015 ,sum(CAST(street1CBDone as integer)) 

7016 ,sum(CAST(street2CBChance as integer)) 

7017 ,sum(CAST(street2CBDone as integer)) 

7018 ,sum(CAST(street3CBChance as integer)) 

7019 ,sum(CAST(street3CBDone as integer)) 

7020 ,sum(CAST(street4CBChance as integer)) 

7021 ,sum(CAST(street4CBDone as integer)) 

7022 ,sum(CAST(foldToStreet1CBChance as integer)) 

7023 ,sum(CAST(foldToStreet1CBDone as integer)) 

7024 ,sum(CAST(foldToStreet2CBChance as integer)) 

7025 ,sum(CAST(foldToStreet2CBDone as integer)) 

7026 ,sum(CAST(foldToStreet3CBChance as integer)) 

7027 ,sum(CAST(foldToStreet3CBDone as integer)) 

7028 ,sum(CAST(foldToStreet4CBChance as integer)) 

7029 ,sum(CAST(foldToStreet4CBDone as integer)) 

7030 ,sum(CAST(common as integer)) 

7031 ,sum(CAST(committed as integer)) 

7032 ,sum(CAST(winnings as integer)) 

7033 ,sum(CAST(rake as integer)) 

7034 ,sum(CAST(rakeDealt as integer)) 

7035 ,sum(CAST(rakeContributed as integer)) 

7036 ,sum(CAST(rakeWeighted as integer)) 

7037 ,sum(CAST(totalProfit as integer)) 

7038 ,sum(allInEV) 

7039 ,sum(CAST(case when sawShowdown = 1 then totalProfit else 0 end as integer)) 

7040 ,sum(CAST(case when sawShowdown = 0 then totalProfit else 0 end as integer)) 

7041 ,sum(CAST(street1CheckCallRaiseChance as integer)) 

7042 ,sum(CAST(street1CheckCallDone as integer)) 

7043 ,sum(CAST(street1CheckRaiseDone as integer)) 

7044 ,sum(CAST(street2CheckCallRaiseChance as integer)) 

7045 ,sum(CAST(street2CheckCallDone as integer)) 

7046 ,sum(CAST(street2CheckRaiseDone as integer)) 

7047 ,sum(CAST(street3CheckCallRaiseChance as integer)) 

7048 ,sum(CAST(street3CheckCallDone as integer)) 

7049 ,sum(CAST(street3CheckRaiseDone as integer)) 

7050 ,sum(CAST(street4CheckCallRaiseChance as integer)) 

7051 ,sum(CAST(street4CheckCallDone as integer)) 

7052 ,sum(CAST(street4CheckRaiseDone as integer)) 

7053 ,sum(CAST(street0Calls as integer)) 

7054 ,sum(CAST(street1Calls as integer)) 

7055 ,sum(CAST(street2Calls as integer)) 

7056 ,sum(CAST(street3Calls as integer)) 

7057 ,sum(CAST(street4Calls as integer)) 

7058 ,sum(CAST(street0Bets as integer)) 

7059 ,sum(CAST(street1Bets as integer)) 

7060 ,sum(CAST(street2Bets as integer)) 

7061 ,sum(CAST(street3Bets as integer)) 

7062 ,sum(CAST(street4Bets as integer)) 

7063 ,sum(CAST(hp.street0Raises as integer)) 

7064 ,sum(CAST(hp.street1Raises as integer)) 

7065 ,sum(CAST(hp.street2Raises as integer)) 

7066 ,sum(CAST(hp.street3Raises as integer)) 

7067 ,sum(CAST(hp.street4Raises as integer)) 

7068 ,sum(CAST(street1Discards as integer)) 

7069 ,sum(CAST(street2Discards as integer)) 

7070 ,sum(CAST(street3Discards as integer)) 

7071 FROM Hands h 

7072 INNER JOIN HandsPlayers hp ON (h.id = hp.handId<hero_join>) 

7073 INNER JOIN Gametypes g ON (h.gametypeId = g.id) 

7074 <sessions_join_clause> 

7075 <tourney_join_clause> 

7076 <where_clause> 

7077 GROUP BY <group> 

7078""" 

7079 

7080 self.query["insert_hudcache"] = """insert into HudCache ( 

7081 gametypeId, 

7082 playerId, 

7083 seats, 

7084 position, 

7085 tourneyTypeId, 

7086 styleKey, 

7087 n, 

7088 street0VPIChance, 

7089 street0VPI, 

7090 street0AggrChance, 

7091 street0Aggr, 

7092 street0CalledRaiseChance, 

7093 street0CalledRaiseDone, 

7094 street0_2BChance, 

7095 street0_2BDone, 

7096 street0_3BChance, 

7097 street0_3BDone, 

7098 street0_4BChance, 

7099 street0_4BDone, 

7100 street0_C4BChance, 

7101 street0_C4BDone, 

7102 street0_FoldTo2BChance, 

7103 street0_FoldTo2BDone, 

7104 street0_FoldTo3BChance, 

7105 street0_FoldTo3BDone, 

7106 street0_FoldTo4BChance, 

7107 street0_FoldTo4BDone, 

7108 street0_SqueezeChance, 

7109 street0_SqueezeDone, 

7110 raiseToStealChance, 

7111 raiseToStealDone, 

7112 stealChance, 

7113 stealDone, 

7114 success_Steal, 

7115 street1Seen, 

7116 street2Seen, 

7117 street3Seen, 

7118 street4Seen, 

7119 sawShowdown, 

7120 street1Aggr, 

7121 street2Aggr, 

7122 street3Aggr, 

7123 street4Aggr, 

7124 otherRaisedStreet0, 

7125 otherRaisedStreet1, 

7126 otherRaisedStreet2, 

7127 otherRaisedStreet3, 

7128 otherRaisedStreet4, 

7129 foldToOtherRaisedStreet0, 

7130 foldToOtherRaisedStreet1, 

7131 foldToOtherRaisedStreet2, 

7132 foldToOtherRaisedStreet3, 

7133 foldToOtherRaisedStreet4, 

7134 wonWhenSeenStreet1, 

7135 wonWhenSeenStreet2, 

7136 wonWhenSeenStreet3, 

7137 wonWhenSeenStreet4, 

7138 wonAtSD, 

7139 raiseFirstInChance, 

7140 raisedFirstIn, 

7141 foldBbToStealChance, 

7142 foldedBbToSteal, 

7143 foldSbToStealChance, 

7144 foldedSbToSteal, 

7145 street1CBChance, 

7146 street1CBDone, 

7147 street2CBChance, 

7148 street2CBDone, 

7149 street3CBChance, 

7150 street3CBDone, 

7151 street4CBChance, 

7152 street4CBDone, 

7153 foldToStreet1CBChance, 

7154 foldToStreet1CBDone, 

7155 foldToStreet2CBChance, 

7156 foldToStreet2CBDone, 

7157 foldToStreet3CBChance, 

7158 foldToStreet3CBDone, 

7159 foldToStreet4CBChance, 

7160 foldToStreet4CBDone, 

7161 common, 

7162 committed, 

7163 winnings, 

7164 rake, 

7165 rakeDealt, 

7166 rakeContributed, 

7167 rakeWeighted, 

7168 totalProfit, 

7169 allInEV, 

7170 showdownWinnings, 

7171 nonShowdownWinnings, 

7172 street1CheckCallRaiseChance, 

7173 street1CheckCallDone, 

7174 street1CheckRaiseDone, 

7175 street2CheckCallRaiseChance, 

7176 street2CheckCallDone, 

7177 street2CheckRaiseDone, 

7178 street3CheckCallRaiseChance, 

7179 street3CheckCallDone, 

7180 street3CheckRaiseDone, 

7181 street4CheckCallRaiseChance, 

7182 street4CheckCallDone, 

7183 street4CheckRaiseDone, 

7184 street0Calls, 

7185 street1Calls, 

7186 street2Calls, 

7187 street3Calls, 

7188 street4Calls, 

7189 street0Bets, 

7190 street1Bets, 

7191 street2Bets, 

7192 street3Bets, 

7193 street4Bets, 

7194 street0Raises, 

7195 street1Raises, 

7196 street2Raises, 

7197 street3Raises, 

7198 street4Raises, 

7199 street1Discards, 

7200 street2Discards, 

7201 street3Discards) 

7202 values (%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, %s, %s, %s, %s, 

7213 %s, %s, %s, %s, %s, 

7214 %s, %s, %s, %s, %s, 

7215 %s, %s, %s, %s, %s, 

7216 %s, %s, %s, %s, %s, 

7217 %s, %s, %s, %s, %s, 

7218 %s, %s, %s, %s, %s, 

7219 %s, %s, %s, %s, %s, 

7220 %s, %s, %s, %s, %s, 

7221 %s, %s, %s, %s, %s, 

7222 %s, %s, %s, %s, %s, 

7223 %s, %s, %s, %s, %s, 

7224 %s, %s, %s, %s, %s, 

7225 %s, %s, %s, %s, %s, 

7226 %s)""" 

7227 

7228 self.query["update_hudcache"] = """ 

7229 UPDATE HudCache SET 

7230 n=n+%s, 

7231 street0VPIChance=street0VPIChance+%s, 

7232 street0VPI=street0VPI+%s, 

7233 street0AggrChance=street0AggrChance+%s, 

7234 street0Aggr=street0Aggr+%s, 

7235 street0CalledRaiseChance=street0CalledRaiseChance+%s, 

7236 street0CalledRaiseDone=street0CalledRaiseDone+%s, 

7237 street0_2BChance=street0_2BChance+%s, 

7238 street0_2BDone=street0_2BDone+%s, 

7239 street0_3BChance=street0_3BChance+%s, 

7240 street0_3BDone=street0_3BDone+%s, 

7241 street0_4BChance=street0_4BChance+%s, 

7242 street0_4BDone=street0_4BDone+%s, 

7243 street0_C4BChance=street0_C4BChance+%s, 

7244 street0_C4BDone=street0_C4BDone+%s, 

7245 street0_FoldTo2BChance=street0_FoldTo2BChance+%s, 

7246 street0_FoldTo2BDone=street0_FoldTo2BDone+%s, 

7247 street0_FoldTo3BChance=street0_FoldTo3BChance+%s, 

7248 street0_FoldTo3BDone=street0_FoldTo3BDone+%s, 

7249 street0_FoldTo4BChance=street0_FoldTo4BChance+%s, 

7250 street0_FoldTo4BDone=street0_FoldTo4BDone+%s, 

7251 street0_SqueezeChance=street0_SqueezeChance+%s, 

7252 street0_SqueezeDone=street0_SqueezeDone+%s, 

7253 raiseToStealChance=raiseToStealChance+%s, 

7254 raiseToStealDone=raiseToStealDone+%s, 

7255 stealChance=stealChance+%s, 

7256 stealDone=stealDone+%s, 

7257 success_Steal=success_Steal+%s, 

7258 street1Seen=street1Seen+%s, 

7259 street2Seen=street2Seen+%s, 

7260 street3Seen=street3Seen+%s, 

7261 street4Seen=street4Seen+%s, 

7262 sawShowdown=sawShowdown+%s, 

7263 street1Aggr=street1Aggr+%s, 

7264 street2Aggr=street2Aggr+%s, 

7265 street3Aggr=street3Aggr+%s, 

7266 street4Aggr=street4Aggr+%s, 

7267 otherRaisedStreet0=otherRaisedStreet0+%s, 

7268 otherRaisedStreet1=otherRaisedStreet1+%s, 

7269 otherRaisedStreet2=otherRaisedStreet2+%s, 

7270 otherRaisedStreet3=otherRaisedStreet3+%s, 

7271 otherRaisedStreet4=otherRaisedStreet4+%s, 

7272 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s, 

7273 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s, 

7274 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s, 

7275 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s, 

7276 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, 

7277 wonWhenSeenStreet1=wonWhenSeenStreet1+%s, 

7278 wonWhenSeenStreet2=wonWhenSeenStreet2+%s, 

7279 wonWhenSeenStreet3=wonWhenSeenStreet3+%s, 

7280 wonWhenSeenStreet4=wonWhenSeenStreet4+%s, 

7281 wonAtSD=wonAtSD+%s, 

7282 raiseFirstInChance=raiseFirstInChance+%s, 

7283 raisedFirstIn=raisedFirstIn+%s, 

7284 foldBbToStealChance=foldBbToStealChance+%s, 

7285 foldedBbToSteal=foldedBbToSteal+%s, 

7286 foldSbToStealChance=foldSbToStealChance+%s, 

7287 foldedSbToSteal=foldedSbToSteal+%s, 

7288 street1CBChance=street1CBChance+%s, 

7289 street1CBDone=street1CBDone+%s, 

7290 street2CBChance=street2CBChance+%s, 

7291 street2CBDone=street2CBDone+%s, 

7292 street3CBChance=street3CBChance+%s, 

7293 street3CBDone=street3CBDone+%s, 

7294 street4CBChance=street4CBChance+%s, 

7295 street4CBDone=street4CBDone+%s, 

7296 foldToStreet1CBChance=foldToStreet1CBChance+%s, 

7297 foldToStreet1CBDone=foldToStreet1CBDone+%s, 

7298 foldToStreet2CBChance=foldToStreet2CBChance+%s, 

7299 foldToStreet2CBDone=foldToStreet2CBDone+%s, 

7300 foldToStreet3CBChance=foldToStreet3CBChance+%s, 

7301 foldToStreet3CBDone=foldToStreet3CBDone+%s, 

7302 foldToStreet4CBChance=foldToStreet4CBChance+%s, 

7303 foldToStreet4CBDone=foldToStreet4CBDone+%s, 

7304 common=common+%s, 

7305 committed=committed+%s, 

7306 winnings=winnings+%s, 

7307 rake=rake+%s, 

7308 rakeDealt=rakeDealt+%s, 

7309 rakeContributed=rakeContributed+%s, 

7310 rakeWeighted=rakeWeighted+%s, 

7311 totalProfit=totalProfit+%s, 

7312 allInEV=allInEV+%s, 

7313 showdownWinnings=showdownWinnings+%s, 

7314 nonShowdownWinnings=nonShowdownWinnings+%s, 

7315 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s, 

7316 street1CheckCallDone=street1CheckCallDone+%s, 

7317 street1CheckRaiseDone=street1CheckRaiseDone+%s, 

7318 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s, 

7319 street2CheckCallDone=street2CheckCallDone+%s, 

7320 street2CheckRaiseDone=street2CheckRaiseDone+%s, 

7321 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, 

7322 street3CheckCallDone=street3CheckCallDone+%s, 

7323 street3CheckRaiseDone=street3CheckRaiseDone+%s, 

7324 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, 

7325 street4CheckCallDone=street4CheckCallDone+%s, 

7326 street4CheckRaiseDone=street4CheckRaiseDone+%s, 

7327 street0Calls=street0Calls+%s, 

7328 street1Calls=street1Calls+%s, 

7329 street2Calls=street2Calls+%s, 

7330 street3Calls=street3Calls+%s, 

7331 street4Calls=street4Calls+%s, 

7332 street0Bets=street0Bets+%s,  

7333 street1Bets=street1Bets+%s, 

7334 street2Bets=street2Bets+%s,  

7335 street3Bets=street3Bets+%s, 

7336 street4Bets=street4Bets+%s,  

7337 street0Raises=street0Raises+%s, 

7338 street1Raises=street1Raises+%s, 

7339 street2Raises=street2Raises+%s, 

7340 street3Raises=street3Raises+%s, 

7341 street4Raises=street4Raises+%s,  

7342 street1Discards=street1Discards+%s, 

7343 street2Discards=street2Discards+%s, 

7344 street3Discards=street3Discards+%s 

7345 WHERE id=%s""" 

7346 

7347 self.query["select_hudcache_ring"] = """ 

7348 SELECT id 

7349 FROM HudCache 

7350 WHERE gametypeId=%s 

7351 AND playerId=%s 

7352 AND seats=%s 

7353 AND position=%s 

7354 AND tourneyTypeId is NULL 

7355 AND styleKey = %s""" 

7356 

7357 self.query["select_hudcache_tour"] = """ 

7358 SELECT id 

7359 FROM HudCache 

7360 WHERE gametypeId=%s 

7361 AND playerId=%s 

7362 AND seats=%s 

7363 AND position=%s 

7364 AND tourneyTypeId=%s 

7365 AND styleKey = %s""" 

7366 

7367 self.query["get_hero_hudcache_start"] = """select min(hc.styleKey) 

7368 from HudCache hc 

7369 where hc.playerId in <playerid_list> 

7370 and hc.styleKey like 'd%'""" 

7371 

7372 #################################### 

7373 # Queries to insert/update cardscache 

7374 #################################### 

7375 

7376 self.query["insert_cardscache"] = """insert into CardsCache ( 

7377 weekId, 

7378 monthId, 

7379 gametypeId, 

7380 tourneyTypeId, 

7381 playerId, 

7382 startCards, 

7383 n, 

7384 street0VPIChance, 

7385 street0VPI, 

7386 street0AggrChance, 

7387 street0Aggr, 

7388 street0CalledRaiseChance, 

7389 street0CalledRaiseDone, 

7390 street0_3BChance, 

7391 street0_3BDone, 

7392 street0_2BChance, 

7393 street0_2BDone, 

7394 street0_4BChance, 

7395 street0_4BDone, 

7396 street0_C4BChance, 

7397 street0_C4BDone, 

7398 street0_FoldTo2BChance, 

7399 street0_FoldTo2BDone, 

7400 street0_FoldTo3BChance, 

7401 street0_FoldTo3BDone, 

7402 street0_FoldTo4BChance, 

7403 street0_FoldTo4BDone, 

7404 street0_SqueezeChance, 

7405 street0_SqueezeDone, 

7406 raiseToStealChance, 

7407 raiseToStealDone, 

7408 stealChance, 

7409 stealDone, 

7410 success_Steal, 

7411 street1Seen, 

7412 street2Seen, 

7413 street3Seen, 

7414 street4Seen, 

7415 sawShowdown, 

7416 street1Aggr, 

7417 street2Aggr, 

7418 street3Aggr, 

7419 street4Aggr, 

7420 otherRaisedStreet0, 

7421 otherRaisedStreet1, 

7422 otherRaisedStreet2, 

7423 otherRaisedStreet3, 

7424 otherRaisedStreet4, 

7425 foldToOtherRaisedStreet0, 

7426 foldToOtherRaisedStreet1, 

7427 foldToOtherRaisedStreet2, 

7428 foldToOtherRaisedStreet3, 

7429 foldToOtherRaisedStreet4, 

7430 wonWhenSeenStreet1, 

7431 wonWhenSeenStreet2, 

7432 wonWhenSeenStreet3, 

7433 wonWhenSeenStreet4, 

7434 wonAtSD, 

7435 raiseFirstInChance, 

7436 raisedFirstIn, 

7437 foldBbToStealChance, 

7438 foldedBbToSteal, 

7439 foldSbToStealChance, 

7440 foldedSbToSteal, 

7441 street1CBChance, 

7442 street1CBDone, 

7443 street2CBChance, 

7444 street2CBDone, 

7445 street3CBChance, 

7446 street3CBDone, 

7447 street4CBChance, 

7448 street4CBDone, 

7449 foldToStreet1CBChance, 

7450 foldToStreet1CBDone, 

7451 foldToStreet2CBChance, 

7452 foldToStreet2CBDone, 

7453 foldToStreet3CBChance, 

7454 foldToStreet3CBDone, 

7455 foldToStreet4CBChance, 

7456 foldToStreet4CBDone, 

7457 common, 

7458 committed, 

7459 winnings, 

7460 rake, 

7461 rakeDealt, 

7462 rakeContributed, 

7463 rakeWeighted, 

7464 totalProfit, 

7465 allInEV, 

7466 showdownWinnings, 

7467 nonShowdownWinnings, 

7468 street1CheckCallRaiseChance, 

7469 street1CheckCallDone, 

7470 street1CheckRaiseDone, 

7471 street2CheckCallRaiseChance, 

7472 street2CheckCallDone, 

7473 street2CheckRaiseDone, 

7474 street3CheckCallRaiseChance, 

7475 street3CheckCallDone, 

7476 street3CheckRaiseDone, 

7477 street4CheckCallRaiseChance, 

7478 street4CheckCallDone, 

7479 street4CheckRaiseDone, 

7480 street0Calls, 

7481 street1Calls, 

7482 street2Calls, 

7483 street3Calls, 

7484 street4Calls, 

7485 street0Bets, 

7486 street1Bets, 

7487 street2Bets, 

7488 street3Bets, 

7489 street4Bets, 

7490 street0Raises, 

7491 street1Raises, 

7492 street2Raises, 

7493 street3Raises, 

7494 street4Raises, 

7495 street1Discards, 

7496 street2Discards, 

7497 street3Discards) 

7498 values (%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, %s, %s, %s, %s, 

7509 %s, %s, %s, %s, %s, 

7510 %s, %s, %s, %s, %s, 

7511 %s, %s, %s, %s, %s, 

7512 %s, %s, %s, %s, %s, 

7513 %s, %s, %s, %s, %s, 

7514 %s, %s, %s, %s, %s, 

7515 %s, %s, %s, %s, %s, 

7516 %s, %s, %s, %s, %s, 

7517 %s, %s, %s, %s, %s, 

7518 %s, %s, %s, %s, %s, 

7519 %s, %s, %s, %s, %s, 

7520 %s, %s, %s, %s, %s, 

7521 %s, %s, %s, %s, %s, 

7522 %s)""" 

7523 

7524 self.query["update_cardscache"] = """ 

7525 UPDATE CardsCache SET 

7526 n=n+%s, 

7527 street0VPIChance=street0VPIChance+%s, 

7528 street0VPI=street0VPI+%s, 

7529 street0AggrChance=street0AggrChance+%s, 

7530 street0Aggr=street0Aggr+%s, 

7531 street0CalledRaiseChance=street0CalledRaiseChance+%s, 

7532 street0CalledRaiseDone=street0CalledRaiseDone+%s, 

7533 street0_2BChance=street0_2BChance+%s, 

7534 street0_2BDone=street0_2BDone+%s, 

7535 street0_3BChance=street0_3BChance+%s, 

7536 street0_3BDone=street0_3BDone+%s, 

7537 street0_4BChance=street0_4BChance+%s, 

7538 street0_4BDone=street0_4BDone+%s, 

7539 street0_C4BChance=street0_C4BChance+%s, 

7540 street0_C4BDone=street0_C4BDone+%s, 

7541 street0_FoldTo2BChance=street0_FoldTo2BChance+%s, 

7542 street0_FoldTo2BDone=street0_FoldTo2BDone+%s, 

7543 street0_FoldTo3BChance=street0_FoldTo3BChance+%s, 

7544 street0_FoldTo3BDone=street0_FoldTo3BDone+%s, 

7545 street0_FoldTo4BChance=street0_FoldTo4BChance+%s, 

7546 street0_FoldTo4BDone=street0_FoldTo4BDone+%s, 

7547 street0_SqueezeChance=street0_SqueezeChance+%s, 

7548 street0_SqueezeDone=street0_SqueezeDone+%s, 

7549 raiseToStealChance=raiseToStealChance+%s, 

7550 raiseToStealDone=raiseToStealDone+%s, 

7551 stealChance=stealChance+%s, 

7552 stealDone=stealDone+%s, 

7553 success_Steal=success_Steal+%s, 

7554 street1Seen=street1Seen+%s, 

7555 street2Seen=street2Seen+%s, 

7556 street3Seen=street3Seen+%s, 

7557 street4Seen=street4Seen+%s, 

7558 sawShowdown=sawShowdown+%s, 

7559 street1Aggr=street1Aggr+%s, 

7560 street2Aggr=street2Aggr+%s, 

7561 street3Aggr=street3Aggr+%s, 

7562 street4Aggr=street4Aggr+%s, 

7563 otherRaisedStreet0=otherRaisedStreet0+%s, 

7564 otherRaisedStreet1=otherRaisedStreet1+%s, 

7565 otherRaisedStreet2=otherRaisedStreet2+%s, 

7566 otherRaisedStreet3=otherRaisedStreet3+%s, 

7567 otherRaisedStreet4=otherRaisedStreet4+%s, 

7568 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s, 

7569 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s, 

7570 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s, 

7571 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s, 

7572 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, 

7573 wonWhenSeenStreet1=wonWhenSeenStreet1+%s, 

7574 wonWhenSeenStreet2=wonWhenSeenStreet2+%s, 

7575 wonWhenSeenStreet3=wonWhenSeenStreet3+%s, 

7576 wonWhenSeenStreet4=wonWhenSeenStreet4+%s, 

7577 wonAtSD=wonAtSD+%s, 

7578 raiseFirstInChance=raiseFirstInChance+%s, 

7579 raisedFirstIn=raisedFirstIn+%s, 

7580 foldBbToStealChance=foldBbToStealChance+%s, 

7581 foldedBbToSteal=foldedBbToSteal+%s, 

7582 foldSbToStealChance=foldSbToStealChance+%s, 

7583 foldedSbToSteal=foldedSbToSteal+%s, 

7584 street1CBChance=street1CBChance+%s, 

7585 street1CBDone=street1CBDone+%s, 

7586 street2CBChance=street2CBChance+%s, 

7587 street2CBDone=street2CBDone+%s, 

7588 street3CBChance=street3CBChance+%s, 

7589 street3CBDone=street3CBDone+%s, 

7590 street4CBChance=street4CBChance+%s, 

7591 street4CBDone=street4CBDone+%s, 

7592 foldToStreet1CBChance=foldToStreet1CBChance+%s, 

7593 foldToStreet1CBDone=foldToStreet1CBDone+%s, 

7594 foldToStreet2CBChance=foldToStreet2CBChance+%s, 

7595 foldToStreet2CBDone=foldToStreet2CBDone+%s, 

7596 foldToStreet3CBChance=foldToStreet3CBChance+%s, 

7597 foldToStreet3CBDone=foldToStreet3CBDone+%s, 

7598 foldToStreet4CBChance=foldToStreet4CBChance+%s, 

7599 foldToStreet4CBDone=foldToStreet4CBDone+%s, 

7600 common=common+%s, 

7601 committed=committed+%s, 

7602 winnings=winnings+%s, 

7603 rake=rake+%s, 

7604 rakeDealt=rakeDealt+%s, 

7605 rakeContributed=rakeContributed+%s, 

7606 rakeWeighted=rakeWeighted+%s, 

7607 totalProfit=totalProfit+%s, 

7608 allInEV=allInEV+%s, 

7609 showdownWinnings=showdownWinnings+%s, 

7610 nonShowdownWinnings=nonShowdownWinnings+%s, 

7611 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s, 

7612 street1CheckCallDone=street1CheckCallDone+%s, 

7613 street1CheckRaiseDone=street1CheckRaiseDone+%s, 

7614 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s, 

7615 street2CheckCallDone=street2CheckCallDone+%s, 

7616 street2CheckRaiseDone=street2CheckRaiseDone+%s, 

7617 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, 

7618 street3CheckCallDone=street3CheckCallDone+%s, 

7619 street3CheckRaiseDone=street3CheckRaiseDone+%s, 

7620 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, 

7621 street4CheckCallDone=street4CheckCallDone+%s, 

7622 street4CheckRaiseDone=street4CheckRaiseDone+%s, 

7623 street0Calls=street0Calls+%s, 

7624 street1Calls=street1Calls+%s, 

7625 street2Calls=street2Calls+%s, 

7626 street3Calls=street3Calls+%s, 

7627 street4Calls=street4Calls+%s, 

7628 street0Bets=street0Bets+%s,  

7629 street1Bets=street1Bets+%s, 

7630 street2Bets=street2Bets+%s,  

7631 street3Bets=street3Bets+%s, 

7632 street4Bets=street4Bets+%s,  

7633 street0Raises=street0Raises+%s, 

7634 street1Raises=street1Raises+%s, 

7635 street2Raises=street2Raises+%s, 

7636 street3Raises=street3Raises+%s, 

7637 street4Raises=street4Raises+%s, 

7638 street1Discards=street1Discards+%s, 

7639 street2Discards=street2Discards+%s, 

7640 street3Discards=street3Discards+%s 

7641 WHERE id=%s""" 

7642 

7643 self.query["select_cardscache_ring"] = """ 

7644 SELECT id 

7645 FROM CardsCache 

7646 WHERE weekId=%s 

7647 AND monthId=%s 

7648 AND gametypeId=%s 

7649 AND tourneyTypeId is NULL 

7650 AND playerId=%s 

7651 AND startCards=%s""" 

7652 

7653 self.query["select_cardscache_tour"] = """ 

7654 SELECT id 

7655 FROM CardsCache 

7656 WHERE weekId=%s 

7657 AND monthId=%s 

7658 AND gametypeId=%s 

7659 AND tourneyTypeId=%s 

7660 AND playerId=%s 

7661 AND startCards=%s""" 

7662 

7663 #################################### 

7664 # create comment on players 

7665 #################################### 

7666 

7667 self.query["get_player_comment"] = """ 

7668 SELECT comment FROM Players WHERE id=%s 

7669 """ 

7670 

7671 self.query["update_player_comment"] = """ 

7672 UPDATE Players SET comment=%s, commentTs=CURRENT_TIMESTAMP WHERE id=%s 

7673 """ 

7674 self.query["get_player_name"] = "SELECT name FROM Players WHERE id=%s" 

7675 

7676 #################################### 

7677 

7678 #################################### 

7679 # Queries to insert/update positionscache 

7680 #################################### 

7681 

7682 self.query["insert_positionscache"] = """insert into PositionsCache ( 

7683 weekId, 

7684 monthId, 

7685 gametypeId, 

7686 tourneyTypeId, 

7687 playerId, 

7688 seats, 

7689 maxPosition, 

7690 position, 

7691 n, 

7692 street0VPIChance, 

7693 street0VPI, 

7694 street0AggrChance, 

7695 street0Aggr, 

7696 street0CalledRaiseChance, 

7697 street0CalledRaiseDone, 

7698 street0_2BChance, 

7699 street0_2BDone, 

7700 street0_3BChance, 

7701 street0_3BDone, 

7702 street0_4BChance, 

7703 street0_4BDone, 

7704 street0_C4BChance, 

7705 street0_C4BDone, 

7706 street0_FoldTo2BChance, 

7707 street0_FoldTo2BDone, 

7708 street0_FoldTo3BChance, 

7709 street0_FoldTo3BDone, 

7710 street0_FoldTo4BChance, 

7711 street0_FoldTo4BDone, 

7712 street0_SqueezeChance, 

7713 street0_SqueezeDone, 

7714 raiseToStealChance, 

7715 raiseToStealDone, 

7716 stealChance, 

7717 stealDone, 

7718 success_Steal, 

7719 street1Seen, 

7720 street2Seen, 

7721 street3Seen, 

7722 street4Seen, 

7723 sawShowdown, 

7724 street1Aggr, 

7725 street2Aggr, 

7726 street3Aggr, 

7727 street4Aggr, 

7728 otherRaisedStreet0, 

7729 otherRaisedStreet1, 

7730 otherRaisedStreet2, 

7731 otherRaisedStreet3, 

7732 otherRaisedStreet4, 

7733 foldToOtherRaisedStreet0, 

7734 foldToOtherRaisedStreet1, 

7735 foldToOtherRaisedStreet2, 

7736 foldToOtherRaisedStreet3, 

7737 foldToOtherRaisedStreet4, 

7738 wonWhenSeenStreet1, 

7739 wonWhenSeenStreet2, 

7740 wonWhenSeenStreet3, 

7741 wonWhenSeenStreet4, 

7742 wonAtSD, 

7743 raiseFirstInChance, 

7744 raisedFirstIn, 

7745 foldBbToStealChance, 

7746 foldedBbToSteal, 

7747 foldSbToStealChance, 

7748 foldedSbToSteal, 

7749 street1CBChance, 

7750 street1CBDone, 

7751 street2CBChance, 

7752 street2CBDone, 

7753 street3CBChance, 

7754 street3CBDone, 

7755 street4CBChance, 

7756 street4CBDone, 

7757 foldToStreet1CBChance, 

7758 foldToStreet1CBDone, 

7759 foldToStreet2CBChance, 

7760 foldToStreet2CBDone, 

7761 foldToStreet3CBChance, 

7762 foldToStreet3CBDone, 

7763 foldToStreet4CBChance, 

7764 foldToStreet4CBDone, 

7765 common, 

7766 committed, 

7767 winnings, 

7768 rake, 

7769 rakeDealt, 

7770 rakeContributed, 

7771 rakeWeighted, 

7772 totalProfit, 

7773 allInEV, 

7774 showdownWinnings, 

7775 nonShowdownWinnings, 

7776 street1CheckCallRaiseChance, 

7777 street1CheckCallDone, 

7778 street1CheckRaiseDone, 

7779 street2CheckCallRaiseChance, 

7780 street2CheckCallDone, 

7781 street2CheckRaiseDone, 

7782 street3CheckCallRaiseChance, 

7783 street3CheckCallDone, 

7784 street3CheckRaiseDone, 

7785 street4CheckCallRaiseChance, 

7786 street4CheckCallDone, 

7787 street4CheckRaiseDone, 

7788 street0Calls, 

7789 street1Calls, 

7790 street2Calls, 

7791 street3Calls, 

7792 street4Calls, 

7793 street0Bets, 

7794 street1Bets, 

7795 street2Bets, 

7796 street3Bets, 

7797 street4Bets, 

7798 street0Raises, 

7799 street1Raises, 

7800 street2Raises, 

7801 street3Raises, 

7802 street4Raises, 

7803 street1Discards, 

7804 street2Discards, 

7805 street3Discards) 

7806 values (%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, %s, %s, 

7818 %s, %s, %s, %s, %s, 

7819 %s, %s, %s, %s, %s, 

7820 %s, %s, %s, %s, %s, 

7821 %s, %s, %s, %s, %s, 

7822 %s, %s, %s, %s, %s, 

7823 %s, %s, %s, %s, %s, 

7824 %s, %s, %s, %s, %s, 

7825 %s, %s, %s, %s, %s, 

7826 %s, %s, %s, %s, %s, 

7827 %s, %s, %s, %s, %s, 

7828 %s, %s, %s, %s, %s, 

7829 %s, %s, %s, %s, %s, 

7830 %s, %s, %s 

7831 )""" 

7832 

7833 self.query["update_positionscache"] = """ 

7834 UPDATE PositionsCache SET 

7835 n=n+%s, 

7836 street0VPIChance=street0VPIChance+%s, 

7837 street0VPI=street0VPI+%s, 

7838 street0AggrChance=street0AggrChance+%s, 

7839 street0Aggr=street0Aggr+%s, 

7840 street0CalledRaiseChance=street0CalledRaiseChance+%s, 

7841 street0CalledRaiseDone=street0CalledRaiseDone+%s, 

7842 street0_2BChance=street0_2BChance+%s, 

7843 street0_2BDone=street0_2BDone+%s, 

7844 street0_3BChance=street0_3BChance+%s, 

7845 street0_3BDone=street0_3BDone+%s, 

7846 street0_4BChance=street0_4BChance+%s, 

7847 street0_4BDone=street0_4BDone+%s, 

7848 street0_C4BChance=street0_C4BChance+%s, 

7849 street0_C4BDone=street0_C4BDone+%s, 

7850 street0_FoldTo2BChance=street0_FoldTo2BChance+%s, 

7851 street0_FoldTo2BDone=street0_FoldTo2BDone+%s, 

7852 street0_FoldTo3BChance=street0_FoldTo3BChance+%s, 

7853 street0_FoldTo3BDone=street0_FoldTo3BDone+%s, 

7854 street0_FoldTo4BChance=street0_FoldTo4BChance+%s, 

7855 street0_FoldTo4BDone=street0_FoldTo4BDone+%s, 

7856 street0_SqueezeChance=street0_SqueezeChance+%s, 

7857 street0_SqueezeDone=street0_SqueezeDone+%s, 

7858 raiseToStealChance=raiseToStealChance+%s, 

7859 raiseToStealDone=raiseToStealDone+%s, 

7860 stealChance=stealChance+%s, 

7861 stealDone=stealDone+%s, 

7862 success_Steal=success_Steal+%s, 

7863 street1Seen=street1Seen+%s, 

7864 street2Seen=street2Seen+%s, 

7865 street3Seen=street3Seen+%s, 

7866 street4Seen=street4Seen+%s, 

7867 sawShowdown=sawShowdown+%s, 

7868 street1Aggr=street1Aggr+%s, 

7869 street2Aggr=street2Aggr+%s, 

7870 street3Aggr=street3Aggr+%s, 

7871 street4Aggr=street4Aggr+%s, 

7872 otherRaisedStreet0=otherRaisedStreet0+%s, 

7873 otherRaisedStreet1=otherRaisedStreet1+%s, 

7874 otherRaisedStreet2=otherRaisedStreet2+%s, 

7875 otherRaisedStreet3=otherRaisedStreet3+%s, 

7876 otherRaisedStreet4=otherRaisedStreet4+%s, 

7877 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s, 

7878 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s, 

7879 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s, 

7880 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s, 

7881 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, 

7882 wonWhenSeenStreet1=wonWhenSeenStreet1+%s, 

7883 wonWhenSeenStreet2=wonWhenSeenStreet2+%s, 

7884 wonWhenSeenStreet3=wonWhenSeenStreet3+%s, 

7885 wonWhenSeenStreet4=wonWhenSeenStreet4+%s, 

7886 wonAtSD=wonAtSD+%s, 

7887 raiseFirstInChance=raiseFirstInChance+%s, 

7888 raisedFirstIn=raisedFirstIn+%s, 

7889 foldBbToStealChance=foldBbToStealChance+%s, 

7890 foldedBbToSteal=foldedBbToSteal+%s, 

7891 foldSbToStealChance=foldSbToStealChance+%s, 

7892 foldedSbToSteal=foldedSbToSteal+%s, 

7893 street1CBChance=street1CBChance+%s, 

7894 street1CBDone=street1CBDone+%s, 

7895 street2CBChance=street2CBChance+%s, 

7896 street2CBDone=street2CBDone+%s, 

7897 street3CBChance=street3CBChance+%s, 

7898 street3CBDone=street3CBDone+%s, 

7899 street4CBChance=street4CBChance+%s, 

7900 street4CBDone=street4CBDone+%s, 

7901 foldToStreet1CBChance=foldToStreet1CBChance+%s, 

7902 foldToStreet1CBDone=foldToStreet1CBDone+%s, 

7903 foldToStreet2CBChance=foldToStreet2CBChance+%s, 

7904 foldToStreet2CBDone=foldToStreet2CBDone+%s, 

7905 foldToStreet3CBChance=foldToStreet3CBChance+%s, 

7906 foldToStreet3CBDone=foldToStreet3CBDone+%s, 

7907 foldToStreet4CBChance=foldToStreet4CBChance+%s, 

7908 foldToStreet4CBDone=foldToStreet4CBDone+%s, 

7909 common=common+%s, 

7910 committed=committed+%s, 

7911 winnings=winnings+%s, 

7912 rake=rake+%s, 

7913 rakeDealt=rakeDealt+%s, 

7914 rakeContributed=rakeContributed+%s, 

7915 rakeWeighted=rakeWeighted+%s, 

7916 totalProfit=totalProfit+%s, 

7917 allInEV=allInEV+%s, 

7918 showdownWinnings=showdownWinnings+%s, 

7919 nonShowdownWinnings=nonShowdownWinnings+%s, 

7920 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s, 

7921 street1CheckCallDone=street1CheckCallDone+%s, 

7922 street1CheckRaiseDone=street1CheckRaiseDone+%s, 

7923 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s, 

7924 street2CheckCallDone=street2CheckCallDone+%s, 

7925 street2CheckRaiseDone=street2CheckRaiseDone+%s, 

7926 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, 

7927 street3CheckCallDone=street3CheckCallDone+%s, 

7928 street3CheckRaiseDone=street3CheckRaiseDone+%s, 

7929 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, 

7930 street4CheckCallDone=street4CheckCallDone+%s, 

7931 street4CheckRaiseDone=street4CheckRaiseDone+%s, 

7932 street0Calls=street0Calls+%s, 

7933 street1Calls=street1Calls+%s, 

7934 street2Calls=street2Calls+%s, 

7935 street3Calls=street3Calls+%s, 

7936 street4Calls=street4Calls+%s, 

7937 street0Bets=street0Bets+%s,  

7938 street1Bets=street1Bets+%s, 

7939 street2Bets=street2Bets+%s,  

7940 street3Bets=street3Bets+%s, 

7941 street4Bets=street4Bets+%s,  

7942 street0Raises=street0Raises+%s, 

7943 street1Raises=street1Raises+%s, 

7944 street2Raises=street2Raises+%s, 

7945 street3Raises=street3Raises+%s, 

7946 street4Raises=street4Raises+%s, 

7947 street1Discards=street1Discards+%s, 

7948 street2Discards=street2Discards+%s, 

7949 street3Discards=street3Discards+%s 

7950 WHERE id=%s""" 

7951 

7952 self.query["select_positionscache_ring"] = """ 

7953 SELECT id 

7954 FROM PositionsCache 

7955 WHERE weekId=%s 

7956 AND monthId=%s 

7957 AND gametypeId=%s 

7958 AND tourneyTypeId is NULL 

7959 AND playerId=%s 

7960 AND seats=%s 

7961 AND maxPosition=%s 

7962 AND position=%s""" 

7963 

7964 self.query["select_positionscache_tour"] = """ 

7965 SELECT id 

7966 FROM PositionsCache 

7967 WHERE weekId=%s 

7968 AND monthId=%s 

7969 AND gametypeId=%s 

7970 AND tourneyTypeId=%s 

7971 AND playerId=%s 

7972 AND seats=%s 

7973 AND maxPosition=%s 

7974 AND position=%s""" 

7975 

7976 #################################### 

7977 # Queries to rebuild/modify sessionscache 

7978 #################################### 

7979 

7980 self.query["clear_S_H"] = "UPDATE Hands SET sessionId = NULL" 

7981 self.query["clear_S_T"] = "UPDATE Tourneys SET sessionId = NULL" 

7982 self.query["clear_S_SC"] = "UPDATE SessionsCache SET sessionId = NULL" 

7983 self.query["clear_S_TC"] = "UPDATE TourneysCache SET sessionId = NULL" 

7984 self.query["clear_W_S"] = "UPDATE Sessions SET weekId = NULL" 

7985 self.query["clear_M_S"] = "UPDATE Sessions SET monthId = NULL" 

7986 self.query["clearSessionsCache"] = "DELETE FROM SessionsCache WHERE 1" 

7987 self.query["clearTourneysCache"] = "DELETE FROM TourneysCache WHERE 1" 

7988 self.query["clearSessions"] = "DELETE FROM Sessions WHERE 1" 

7989 self.query["clearWeeks"] = "DELETE FROM Weeks WHERE 1" 

7990 self.query["clearMonths"] = "DELETE FROM Months WHERE 1" 

7991 self.query["update_RSC_H"] = "UPDATE Hands SET sessionId = %s WHERE id = %s" 

7992 

7993 #################################### 

7994 # select 

7995 #################################### 

7996 

7997 self.query["select_S_all"] = """ 

7998 SELECT SC.id as id, 

7999 sessionStart, 

8000 weekStart, 

8001 monthStart, 

8002 weekId, 

8003 monthId 

8004 FROM Sessions SC 

8005 INNER JOIN Weeks WC ON (SC.weekId = WC.id) 

8006 INNER JOIN Months MC ON (SC.monthId = MC.id) 

8007 WHERE sessionEnd>=%s 

8008 AND sessionStart<=%s""" 

8009 

8010 self.query["select_S"] = """ 

8011 SELECT SC.id as id, 

8012 sessionStart, 

8013 sessionEnd, 

8014 weekStart, 

8015 monthStart, 

8016 weekId, 

8017 monthId 

8018 FROM Sessions SC 

8019 INNER JOIN Weeks WC ON (SC.weekId = WC.id) 

8020 INNER JOIN Months MC ON (SC.monthId = MC.id) 

8021 WHERE (sessionEnd>=%s AND sessionStart<=%s) 

8022 <TOURSELECT>""" 

8023 

8024 self.query["select_W"] = """ 

8025 SELECT id 

8026 FROM Weeks 

8027 WHERE weekStart = %s""" 

8028 

8029 self.query["select_M"] = """ 

8030 SELECT id 

8031 FROM Months 

8032 WHERE monthStart = %s""" 

8033 

8034 self.query["select_SC"] = """ 

8035 SELECT id, 

8036 sessionId, 

8037 startTime, 

8038 endTime, 

8039 n, 

8040 street0VPIChance, 

8041 street0VPI, 

8042 street0AggrChance, 

8043 street0Aggr, 

8044 street0CalledRaiseChance, 

8045 street0CalledRaiseDone, 

8046 street0_2BChance, 

8047 street0_2BDone, 

8048 street0_3BChance, 

8049 street0_3BDone, 

8050 street0_4BChance, 

8051 street0_4BDone, 

8052 street0_C4BChance, 

8053 street0_C4BDone, 

8054 street0_FoldTo2BChance, 

8055 street0_FoldTo2BDone, 

8056 street0_FoldTo3BChance, 

8057 street0_FoldTo3BDone, 

8058 street0_FoldTo4BChance, 

8059 street0_FoldTo4BDone, 

8060 street0_SqueezeChance, 

8061 street0_SqueezeDone, 

8062 raiseToStealChance, 

8063 raiseToStealDone, 

8064 stealChance, 

8065 stealDone, 

8066 success_Steal, 

8067 street1Seen, 

8068 street2Seen, 

8069 street3Seen, 

8070 street4Seen, 

8071 sawShowdown, 

8072 street1Aggr, 

8073 street2Aggr, 

8074 street3Aggr, 

8075 street4Aggr, 

8076 otherRaisedStreet0, 

8077 otherRaisedStreet1, 

8078 otherRaisedStreet2, 

8079 otherRaisedStreet3, 

8080 otherRaisedStreet4, 

8081 foldToOtherRaisedStreet0, 

8082 foldToOtherRaisedStreet1, 

8083 foldToOtherRaisedStreet2, 

8084 foldToOtherRaisedStreet3, 

8085 foldToOtherRaisedStreet4, 

8086 wonWhenSeenStreet1, 

8087 wonWhenSeenStreet2, 

8088 wonWhenSeenStreet3, 

8089 wonWhenSeenStreet4, 

8090 wonAtSD, 

8091 raiseFirstInChance, 

8092 raisedFirstIn, 

8093 foldBbToStealChance, 

8094 foldedBbToSteal, 

8095 foldSbToStealChance, 

8096 foldedSbToSteal, 

8097 street1CBChance, 

8098 street1CBDone, 

8099 street2CBChance, 

8100 street2CBDone, 

8101 street3CBChance, 

8102 street3CBDone, 

8103 street4CBChance, 

8104 street4CBDone, 

8105 foldToStreet1CBChance, 

8106 foldToStreet1CBDone, 

8107 foldToStreet2CBChance, 

8108 foldToStreet2CBDone, 

8109 foldToStreet3CBChance, 

8110 foldToStreet3CBDone, 

8111 foldToStreet4CBChance, 

8112 foldToStreet4CBDone, 

8113 common, 

8114 committed, 

8115 winnings, 

8116 rake, 

8117 rakeDealt, 

8118 rakeContributed, 

8119 rakeWeighted, 

8120 totalProfit, 

8121 allInEV, 

8122 showdownWinnings, 

8123 nonShowdownWinnings, 

8124 street1CheckCallRaiseChance, 

8125 street1CheckCallDone, 

8126 street1CheckRaiseDone, 

8127 street2CheckCallRaiseChance, 

8128 street2CheckCallDone, 

8129 street2CheckRaiseDone, 

8130 street3CheckCallRaiseChance, 

8131 street3CheckCallDone, 

8132 street3CheckRaiseDone, 

8133 street4CheckCallRaiseChance, 

8134 street4CheckCallDone, 

8135 street4CheckRaiseDone, 

8136 street0Calls, 

8137 street1Calls, 

8138 street2Calls, 

8139 street3Calls, 

8140 street4Calls, 

8141 street0Bets, 

8142 street1Bets, 

8143 street2Bets, 

8144 street3Bets, 

8145 street4Bets, 

8146 street0Raises, 

8147 street1Raises, 

8148 street2Raises, 

8149 street3Raises, 

8150 street4Raises, 

8151 street1Discards, 

8152 street2Discards, 

8153 street3Discards 

8154 FROM SessionsCache 

8155 WHERE endTime>=%s 

8156 AND startTime<=%s 

8157 AND gametypeId=%s 

8158 AND playerId=%s""" 

8159 

8160 self.query["select_TC"] = """ 

8161 SELECT id, startTime, endTime 

8162 FROM TourneysCache TC 

8163 WHERE tourneyId=%s 

8164 AND playerId=%s""" 

8165 

8166 #################################### 

8167 # insert 

8168 #################################### 

8169 

8170 self.query["insert_W"] = """insert into Weeks ( 

8171 weekStart) 

8172 values (%s)""" 

8173 

8174 self.query["insert_M"] = """insert into Months ( 

8175 monthStart) 

8176 values (%s)""" 

8177 

8178 self.query["insert_S"] = """insert into Sessions ( 

8179 weekId, 

8180 monthId, 

8181 sessionStart, 

8182 sessionEnd) 

8183 values (%s, %s, %s, %s)""" 

8184 

8185 self.query["insert_SC"] = """insert into SessionsCache ( 

8186 sessionId, 

8187 startTime, 

8188 endTime, 

8189 gametypeId, 

8190 playerId, 

8191 n, 

8192 street0VPIChance, 

8193 street0VPI, 

8194 street0AggrChance, 

8195 street0Aggr, 

8196 street0CalledRaiseChance, 

8197 street0CalledRaiseDone, 

8198 street0_2BChance, 

8199 street0_2BDone, 

8200 street0_3BChance, 

8201 street0_3BDone, 

8202 street0_4BChance, 

8203 street0_4BDone, 

8204 street0_C4BChance, 

8205 street0_C4BDone, 

8206 street0_FoldTo2BChance, 

8207 street0_FoldTo2BDone, 

8208 street0_FoldTo3BChance, 

8209 street0_FoldTo3BDone, 

8210 street0_FoldTo4BChance, 

8211 street0_FoldTo4BDone, 

8212 street0_SqueezeChance, 

8213 street0_SqueezeDone, 

8214 raiseToStealChance, 

8215 raiseToStealDone, 

8216 stealChance, 

8217 stealDone, 

8218 success_Steal, 

8219 street1Seen, 

8220 street2Seen, 

8221 street3Seen, 

8222 street4Seen, 

8223 sawShowdown, 

8224 street1Aggr, 

8225 street2Aggr, 

8226 street3Aggr, 

8227 street4Aggr, 

8228 otherRaisedStreet0, 

8229 otherRaisedStreet1, 

8230 otherRaisedStreet2, 

8231 otherRaisedStreet3, 

8232 otherRaisedStreet4, 

8233 foldToOtherRaisedStreet0, 

8234 foldToOtherRaisedStreet1, 

8235 foldToOtherRaisedStreet2, 

8236 foldToOtherRaisedStreet3, 

8237 foldToOtherRaisedStreet4, 

8238 wonWhenSeenStreet1, 

8239 wonWhenSeenStreet2, 

8240 wonWhenSeenStreet3, 

8241 wonWhenSeenStreet4, 

8242 wonAtSD, 

8243 raiseFirstInChance, 

8244 raisedFirstIn, 

8245 foldBbToStealChance, 

8246 foldedBbToSteal, 

8247 foldSbToStealChance, 

8248 foldedSbToSteal, 

8249 street1CBChance, 

8250 street1CBDone, 

8251 street2CBChance, 

8252 street2CBDone, 

8253 street3CBChance, 

8254 street3CBDone, 

8255 street4CBChance, 

8256 street4CBDone, 

8257 foldToStreet1CBChance, 

8258 foldToStreet1CBDone, 

8259 foldToStreet2CBChance, 

8260 foldToStreet2CBDone, 

8261 foldToStreet3CBChance, 

8262 foldToStreet3CBDone, 

8263 foldToStreet4CBChance, 

8264 foldToStreet4CBDone, 

8265 common, 

8266 committed, 

8267 winnings, 

8268 rake, 

8269 rakeDealt, 

8270 rakeContributed, 

8271 rakeWeighted, 

8272 totalProfit, 

8273 allInEV, 

8274 showdownWinnings, 

8275 nonShowdownWinnings, 

8276 street1CheckCallRaiseChance, 

8277 street1CheckCallDone, 

8278 street1CheckRaiseDone, 

8279 street2CheckCallRaiseChance, 

8280 street2CheckCallDone, 

8281 street2CheckRaiseDone, 

8282 street3CheckCallRaiseChance, 

8283 street3CheckCallDone, 

8284 street3CheckRaiseDone, 

8285 street4CheckCallRaiseChance, 

8286 street4CheckCallDone, 

8287 street4CheckRaiseDone, 

8288 street0Calls, 

8289 street1Calls, 

8290 street2Calls, 

8291 street3Calls, 

8292 street4Calls, 

8293 street0Bets, 

8294 street1Bets, 

8295 street2Bets, 

8296 street3Bets, 

8297 street4Bets, 

8298 street0Raises, 

8299 street1Raises, 

8300 street2Raises, 

8301 street3Raises, 

8302 street4Raises, 

8303 street1Discards, 

8304 street2Discards, 

8305 street3Discards 

8306 ) 

8307 values (%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, 

8318 %s, %s, %s, %s, %s, 

8319 %s, %s, %s, %s, %s, 

8320 %s, %s, %s, %s, %s, 

8321 %s, %s, %s, %s, %s, 

8322 %s, %s, %s, %s, %s, 

8323 %s, %s, %s, %s, %s, 

8324 %s, %s, %s, %s, %s, 

8325 %s, %s, %s, %s, %s, 

8326 %s, %s, %s, %s, %s, 

8327 %s, %s, %s, %s, %s, 

8328 %s, %s, %s, %s, %s, 

8329 %s, %s, %s, %s, %s, 

8330 %s, %s, %s, %s, %s)""" 

8331 

8332 self.query["insert_TC"] = """insert into TourneysCache ( 

8333 sessionId, 

8334 startTime, 

8335 endTime, 

8336 tourneyId, 

8337 playerId, 

8338 n, 

8339 street0VPIChance, 

8340 street0VPI, 

8341 street0AggrChance, 

8342 street0Aggr, 

8343 street0CalledRaiseChance, 

8344 street0CalledRaiseDone, 

8345 street0_2BChance, 

8346 street0_2BDone, 

8347 street0_3BChance, 

8348 street0_3BDone, 

8349 street0_4BChance, 

8350 street0_4BDone, 

8351 street0_C4BChance, 

8352 street0_C4BDone, 

8353 street0_FoldTo2BChance, 

8354 street0_FoldTo2BDone, 

8355 street0_FoldTo3BChance, 

8356 street0_FoldTo3BDone, 

8357 street0_FoldTo4BChance, 

8358 street0_FoldTo4BDone, 

8359 street0_SqueezeChance, 

8360 street0_SqueezeDone, 

8361 raiseToStealChance, 

8362 raiseToStealDone, 

8363 stealChance, 

8364 stealDone, 

8365 success_Steal, 

8366 street1Seen, 

8367 street2Seen, 

8368 street3Seen, 

8369 street4Seen, 

8370 sawShowdown, 

8371 street1Aggr, 

8372 street2Aggr, 

8373 street3Aggr, 

8374 street4Aggr, 

8375 otherRaisedStreet0, 

8376 otherRaisedStreet1, 

8377 otherRaisedStreet2, 

8378 otherRaisedStreet3, 

8379 otherRaisedStreet4, 

8380 foldToOtherRaisedStreet0, 

8381 foldToOtherRaisedStreet1, 

8382 foldToOtherRaisedStreet2, 

8383 foldToOtherRaisedStreet3, 

8384 foldToOtherRaisedStreet4, 

8385 wonWhenSeenStreet1, 

8386 wonWhenSeenStreet2, 

8387 wonWhenSeenStreet3, 

8388 wonWhenSeenStreet4, 

8389 wonAtSD, 

8390 raiseFirstInChance, 

8391 raisedFirstIn, 

8392 foldBbToStealChance, 

8393 foldedBbToSteal, 

8394 foldSbToStealChance, 

8395 foldedSbToSteal, 

8396 street1CBChance, 

8397 street1CBDone, 

8398 street2CBChance, 

8399 street2CBDone, 

8400 street3CBChance, 

8401 street3CBDone, 

8402 street4CBChance, 

8403 street4CBDone, 

8404 foldToStreet1CBChance, 

8405 foldToStreet1CBDone, 

8406 foldToStreet2CBChance, 

8407 foldToStreet2CBDone, 

8408 foldToStreet3CBChance, 

8409 foldToStreet3CBDone, 

8410 foldToStreet4CBChance, 

8411 foldToStreet4CBDone, 

8412 common, 

8413 committed, 

8414 winnings, 

8415 rake, 

8416 rakeDealt, 

8417 rakeContributed, 

8418 rakeWeighted, 

8419 totalProfit, 

8420 allInEV, 

8421 showdownWinnings, 

8422 nonShowdownWinnings, 

8423 street1CheckCallRaiseChance, 

8424 street1CheckCallDone, 

8425 street1CheckRaiseDone, 

8426 street2CheckCallRaiseChance, 

8427 street2CheckCallDone, 

8428 street2CheckRaiseDone, 

8429 street3CheckCallRaiseChance, 

8430 street3CheckCallDone, 

8431 street3CheckRaiseDone, 

8432 street4CheckCallRaiseChance, 

8433 street4CheckCallDone, 

8434 street4CheckRaiseDone, 

8435 street0Calls, 

8436 street1Calls, 

8437 street2Calls, 

8438 street3Calls, 

8439 street4Calls, 

8440 street0Bets, 

8441 street1Bets, 

8442 street2Bets, 

8443 street3Bets, 

8444 street4Bets, 

8445 street0Raises, 

8446 street1Raises, 

8447 street2Raises, 

8448 street3Raises, 

8449 street4Raises, 

8450 street1Discards, 

8451 street2Discards, 

8452 street3Discards 

8453 ) 

8454 values (%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, 

8465 %s, %s, %s, %s, %s, 

8466 %s, %s, %s, %s, %s, 

8467 %s, %s, %s, %s, %s, 

8468 %s, %s, %s, %s, %s, 

8469 %s, %s, %s, %s, %s, 

8470 %s, %s, %s, %s, %s, 

8471 %s, %s, %s, %s, %s, 

8472 %s, %s, %s, %s, %s, 

8473 %s, %s, %s, %s, %s, 

8474 %s, %s, %s, %s, %s, 

8475 %s, %s, %s, %s, %s, 

8476 %s, %s, %s, %s, %s, 

8477 %s, %s, %s, %s, %s)""" 

8478 

8479 #################################### 

8480 # update 

8481 #################################### 

8482 

8483 self.query["update_WM_S"] = """ 

8484 UPDATE Sessions SET 

8485 weekId=%s, 

8486 monthId=%s 

8487 WHERE id=%s""" 

8488 

8489 self.query["update_S"] = """ 

8490 UPDATE Sessions SET  

8491 weekId=%s, 

8492 monthId=%s, 

8493 sessionStart=%s, 

8494 sessionEnd=%s 

8495 WHERE id=%s""" 

8496 

8497 self.query["update_SC"] = """ 

8498 UPDATE SessionsCache SET 

8499 startTime=%s, 

8500 endTime=%s, 

8501 n=n+%s, 

8502 street0VPIChance=street0VPIChance+%s, 

8503 street0VPI=street0VPI+%s, 

8504 street0AggrChance=street0AggrChance+%s, 

8505 street0Aggr=street0Aggr+%s, 

8506 street0CalledRaiseChance=street0CalledRaiseChance+%s, 

8507 street0CalledRaiseDone=street0CalledRaiseDone+%s, 

8508 street0_2BChance=street0_2BChance+%s, 

8509 street0_2BDone=street0_2BDone+%s, 

8510 street0_3BChance=street0_3BChance+%s, 

8511 street0_3BDone=street0_3BDone+%s, 

8512 street0_4BChance=street0_4BChance+%s, 

8513 street0_4BDone=street0_4BDone+%s, 

8514 street0_C4BChance=street0_C4BChance+%s, 

8515 street0_C4BDone=street0_C4BDone+%s, 

8516 street0_FoldTo2BChance=street0_FoldTo2BChance+%s, 

8517 street0_FoldTo2BDone=street0_FoldTo2BDone+%s, 

8518 street0_FoldTo3BChance=street0_FoldTo3BChance+%s, 

8519 street0_FoldTo3BDone=street0_FoldTo3BDone+%s, 

8520 street0_FoldTo4BChance=street0_FoldTo4BChance+%s, 

8521 street0_FoldTo4BDone=street0_FoldTo4BDone+%s, 

8522 street0_SqueezeChance=street0_SqueezeChance+%s, 

8523 street0_SqueezeDone=street0_SqueezeDone+%s, 

8524 raiseToStealChance=raiseToStealChance+%s, 

8525 raiseToStealDone=raiseToStealDone+%s, 

8526 stealChance=stealChance+%s, 

8527 stealDone=stealDone+%s, 

8528 success_Steal=success_Steal+%s, 

8529 street1Seen=street1Seen+%s, 

8530 street2Seen=street2Seen+%s, 

8531 street3Seen=street3Seen+%s, 

8532 street4Seen=street4Seen+%s, 

8533 sawShowdown=sawShowdown+%s, 

8534 street1Aggr=street1Aggr+%s, 

8535 street2Aggr=street2Aggr+%s, 

8536 street3Aggr=street3Aggr+%s, 

8537 street4Aggr=street4Aggr+%s, 

8538 otherRaisedStreet0=otherRaisedStreet0+%s, 

8539 otherRaisedStreet1=otherRaisedStreet1+%s, 

8540 otherRaisedStreet2=otherRaisedStreet2+%s, 

8541 otherRaisedStreet3=otherRaisedStreet3+%s, 

8542 otherRaisedStreet4=otherRaisedStreet4+%s, 

8543 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s, 

8544 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s, 

8545 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s, 

8546 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s, 

8547 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, 

8548 wonWhenSeenStreet1=wonWhenSeenStreet1+%s, 

8549 wonWhenSeenStreet2=wonWhenSeenStreet2+%s, 

8550 wonWhenSeenStreet3=wonWhenSeenStreet3+%s, 

8551 wonWhenSeenStreet4=wonWhenSeenStreet4+%s, 

8552 wonAtSD=wonAtSD+%s, 

8553 raiseFirstInChance=raiseFirstInChance+%s, 

8554 raisedFirstIn=raisedFirstIn+%s, 

8555 foldBbToStealChance=foldBbToStealChance+%s, 

8556 foldedBbToSteal=foldedBbToSteal+%s, 

8557 foldSbToStealChance=foldSbToStealChance+%s, 

8558 foldedSbToSteal=foldedSbToSteal+%s, 

8559 street1CBChance=street1CBChance+%s, 

8560 street1CBDone=street1CBDone+%s, 

8561 street2CBChance=street2CBChance+%s, 

8562 street2CBDone=street2CBDone+%s, 

8563 street3CBChance=street3CBChance+%s, 

8564 street3CBDone=street3CBDone+%s, 

8565 street4CBChance=street4CBChance+%s, 

8566 street4CBDone=street4CBDone+%s, 

8567 foldToStreet1CBChance=foldToStreet1CBChance+%s, 

8568 foldToStreet1CBDone=foldToStreet1CBDone+%s, 

8569 foldToStreet2CBChance=foldToStreet2CBChance+%s, 

8570 foldToStreet2CBDone=foldToStreet2CBDone+%s, 

8571 foldToStreet3CBChance=foldToStreet3CBChance+%s, 

8572 foldToStreet3CBDone=foldToStreet3CBDone+%s, 

8573 foldToStreet4CBChance=foldToStreet4CBChance+%s, 

8574 foldToStreet4CBDone=foldToStreet4CBDone+%s, 

8575 common=common+%s, 

8576 committed=committed+%s, 

8577 winnings=winnings+%s, 

8578 rake=rake+%s, 

8579 rakeDealt=rakeDealt+%s, 

8580 rakeContributed=rakeContributed+%s, 

8581 rakeWeighted=rakeWeighted+%s, 

8582 totalProfit=totalProfit+%s, 

8583 allInEV=allInEV+%s, 

8584 showdownWinnings=showdownWinnings+%s, 

8585 nonShowdownWinnings=nonShowdownWinnings+%s, 

8586 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s, 

8587 street1CheckCallDone=street1CheckCallDone+%s, 

8588 street1CheckRaiseDone=street1CheckRaiseDone+%s, 

8589 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s, 

8590 street2CheckCallDone=street2CheckCallDone+%s, 

8591 street2CheckRaiseDone=street2CheckRaiseDone+%s, 

8592 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, 

8593 street3CheckCallDone=street3CheckCallDone+%s, 

8594 street3CheckRaiseDone=street3CheckRaiseDone+%s, 

8595 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, 

8596 street4CheckCallDone=street4CheckCallDone+%s, 

8597 street4CheckRaiseDone=street4CheckRaiseDone+%s, 

8598 street0Calls=street0Calls+%s, 

8599 street1Calls=street1Calls+%s, 

8600 street2Calls=street2Calls+%s, 

8601 street3Calls=street3Calls+%s, 

8602 street4Calls=street4Calls+%s, 

8603 street0Bets=street0Bets+%s,  

8604 street1Bets=street1Bets+%s, 

8605 street2Bets=street2Bets+%s,  

8606 street3Bets=street3Bets+%s, 

8607 street4Bets=street4Bets+%s,  

8608 street0Raises=street0Raises+%s, 

8609 street1Raises=street1Raises+%s, 

8610 street2Raises=street2Raises+%s, 

8611 street3Raises=street3Raises+%s, 

8612 street4Raises=street4Raises+%s, 

8613 street1Discards=street1Discards+%s, 

8614 street2Discards=street2Discards+%s, 

8615 street3Discards=street3Discards+%s 

8616 WHERE id=%s""" 

8617 

8618 self.query["update_TC"] = """ 

8619 UPDATE TourneysCache SET 

8620 <UPDATE> 

8621 n=n+%s, 

8622 street0VPIChance=street0VPIChance+%s, 

8623 street0VPI=street0VPI+%s, 

8624 street0AggrChance=street0AggrChance+%s, 

8625 street0Aggr=street0Aggr+%s, 

8626 street0CalledRaiseChance=street0CalledRaiseChance+%s, 

8627 street0CalledRaiseDone=street0CalledRaiseDone+%s, 

8628 street0_2BChance=street0_2BChance+%s, 

8629 street0_2BDone=street0_2BDone+%s, 

8630 street0_3BChance=street0_3BChance+%s, 

8631 street0_3BDone=street0_3BDone+%s, 

8632 street0_4BChance=street0_4BChance+%s, 

8633 street0_4BDone=street0_4BDone+%s, 

8634 street0_C4BChance=street0_C4BChance+%s, 

8635 street0_C4BDone=street0_C4BDone+%s, 

8636 street0_FoldTo2BChance=street0_FoldTo2BChance+%s, 

8637 street0_FoldTo2BDone=street0_FoldTo2BDone+%s, 

8638 street0_FoldTo3BChance=street0_FoldTo3BChance+%s, 

8639 street0_FoldTo3BDone=street0_FoldTo3BDone+%s, 

8640 street0_FoldTo4BChance=street0_FoldTo4BChance+%s, 

8641 street0_FoldTo4BDone=street0_FoldTo4BDone+%s, 

8642 street0_SqueezeChance=street0_SqueezeChance+%s, 

8643 street0_SqueezeDone=street0_SqueezeDone+%s, 

8644 raiseToStealChance=raiseToStealChance+%s, 

8645 raiseToStealDone=raiseToStealDone+%s, 

8646 stealChance=stealChance+%s, 

8647 stealDone=stealDone+%s, 

8648 success_Steal=success_Steal+%s, 

8649 street1Seen=street1Seen+%s, 

8650 street2Seen=street2Seen+%s, 

8651 street3Seen=street3Seen+%s, 

8652 street4Seen=street4Seen+%s, 

8653 sawShowdown=sawShowdown+%s, 

8654 street1Aggr=street1Aggr+%s, 

8655 street2Aggr=street2Aggr+%s, 

8656 street3Aggr=street3Aggr+%s, 

8657 street4Aggr=street4Aggr+%s, 

8658 otherRaisedStreet0=otherRaisedStreet0+%s, 

8659 otherRaisedStreet1=otherRaisedStreet1+%s, 

8660 otherRaisedStreet2=otherRaisedStreet2+%s, 

8661 otherRaisedStreet3=otherRaisedStreet3+%s, 

8662 otherRaisedStreet4=otherRaisedStreet4+%s, 

8663 foldToOtherRaisedStreet0=foldToOtherRaisedStreet0+%s, 

8664 foldToOtherRaisedStreet1=foldToOtherRaisedStreet1+%s, 

8665 foldToOtherRaisedStreet2=foldToOtherRaisedStreet2+%s, 

8666 foldToOtherRaisedStreet3=foldToOtherRaisedStreet3+%s, 

8667 foldToOtherRaisedStreet4=foldToOtherRaisedStreet4+%s, 

8668 wonWhenSeenStreet1=wonWhenSeenStreet1+%s, 

8669 wonWhenSeenStreet2=wonWhenSeenStreet2+%s, 

8670 wonWhenSeenStreet3=wonWhenSeenStreet3+%s, 

8671 wonWhenSeenStreet4=wonWhenSeenStreet4+%s, 

8672 wonAtSD=wonAtSD+%s, 

8673 raiseFirstInChance=raiseFirstInChance+%s, 

8674 raisedFirstIn=raisedFirstIn+%s, 

8675 foldBbToStealChance=foldBbToStealChance+%s, 

8676 foldedBbToSteal=foldedBbToSteal+%s, 

8677 foldSbToStealChance=foldSbToStealChance+%s, 

8678 foldedSbToSteal=foldedSbToSteal+%s, 

8679 street1CBChance=street1CBChance+%s, 

8680 street1CBDone=street1CBDone+%s, 

8681 street2CBChance=street2CBChance+%s, 

8682 street2CBDone=street2CBDone+%s, 

8683 street3CBChance=street3CBChance+%s, 

8684 street3CBDone=street3CBDone+%s, 

8685 street4CBChance=street4CBChance+%s, 

8686 street4CBDone=street4CBDone+%s, 

8687 foldToStreet1CBChance=foldToStreet1CBChance+%s, 

8688 foldToStreet1CBDone=foldToStreet1CBDone+%s, 

8689 foldToStreet2CBChance=foldToStreet2CBChance+%s, 

8690 foldToStreet2CBDone=foldToStreet2CBDone+%s, 

8691 foldToStreet3CBChance=foldToStreet3CBChance+%s, 

8692 foldToStreet3CBDone=foldToStreet3CBDone+%s, 

8693 foldToStreet4CBChance=foldToStreet4CBChance+%s, 

8694 foldToStreet4CBDone=foldToStreet4CBDone+%s, 

8695 common=common+%s, 

8696 committed=committed+%s, 

8697 winnings=winnings+%s, 

8698 rake=rake+%s, 

8699 rakeDealt=rakeDealt+%s, 

8700 rakeContributed=rakeContributed+%s, 

8701 rakeWeighted=rakeWeighted+%s, 

8702 totalProfit=totalProfit+%s, 

8703 allInEV=allInEV+%s, 

8704 showdownWinnings=showdownWinnings+%s, 

8705 nonShowdownWinnings=nonShowdownWinnings+%s, 

8706 street1CheckCallRaiseChance=street1CheckCallRaiseChance+%s, 

8707 street1CheckCallDone=street1CheckCallDone+%s, 

8708 street1CheckRaiseDone=street1CheckRaiseDone+%s, 

8709 street2CheckCallRaiseChance=street2CheckCallRaiseChance+%s, 

8710 street2CheckCallDone=street2CheckCallDone+%s, 

8711 street2CheckRaiseDone=street2CheckRaiseDone+%s, 

8712 street3CheckCallRaiseChance=street3CheckCallRaiseChance+%s, 

8713 street3CheckCallDone=street3CheckCallDone+%s, 

8714 street3CheckRaiseDone=street3CheckRaiseDone+%s, 

8715 street4CheckCallRaiseChance=street4CheckCallRaiseChance+%s, 

8716 street4CheckCallDone=street4CheckCallDone+%s, 

8717 street4CheckRaiseDone=street4CheckRaiseDone+%s, 

8718 street0Calls=street0Calls+%s, 

8719 street1Calls=street1Calls+%s, 

8720 street2Calls=street2Calls+%s, 

8721 street3Calls=street3Calls+%s, 

8722 street4Calls=street4Calls+%s, 

8723 street0Bets=street0Bets+%s,  

8724 street1Bets=street1Bets+%s, 

8725 street2Bets=street2Bets+%s,  

8726 street3Bets=street3Bets+%s, 

8727 street4Bets=street4Bets+%s,  

8728 street0Raises=street0Raises+%s, 

8729 street1Raises=street1Raises+%s, 

8730 street2Raises=street2Raises+%s, 

8731 street3Raises=street3Raises+%s, 

8732 street4Raises=street4Raises+%s, 

8733 street1Discards=street1Discards+%s, 

8734 street2Discards=street2Discards+%s, 

8735 street3Discards=street3Discards+%s 

8736 WHERE tourneyId=%s 

8737 AND playerId=%s""" 

8738 

8739 #################################### 

8740 # delete 

8741 #################################### 

8742 

8743 self.query["delete_S"] = """ 

8744 DELETE FROM Sessions 

8745 WHERE id=%s""" 

8746 

8747 self.query["delete_SC"] = """ 

8748 DELETE FROM SessionsCache 

8749 WHERE id=%s""" 

8750 

8751 #################################### 

8752 # update SessionsCache, Hands, Tourneys 

8753 #################################### 

8754 

8755 self.query["update_S_SC"] = """ 

8756 UPDATE SessionsCache SET 

8757 sessionId=%s 

8758 WHERE sessionId=%s""" 

8759 

8760 self.query["update_S_TC"] = """ 

8761 UPDATE TourneysCache SET 

8762 sessionId=%s 

8763 WHERE sessionId=%s""" 

8764 

8765 self.query["update_S_T"] = """ 

8766 UPDATE Tourneys SET 

8767 sessionId=%s 

8768 WHERE sessionId=%s""" 

8769 

8770 self.query["update_S_H"] = """ 

8771 UPDATE Hands SET 

8772 sessionId=%s 

8773 WHERE sessionId=%s""" 

8774 

8775 #################################### 

8776 # update Tourneys w. sessionIds, hands, start/end 

8777 #################################### 

8778 

8779 self.query["updateTourneysSessions"] = """ 

8780 UPDATE Tourneys SET 

8781 sessionId=%s 

8782 WHERE id=%s""" 

8783 

8784 #################################### 

8785 # Database management queries 

8786 #################################### 

8787 

8788 if db_server == "mysql": 

8789 self.query["analyze"] = """ 

8790 analyze table Actions, Autorates, Backings, Boards, Files, Gametypes, Hands, HandsActions, HandsPlayers,  

8791 HandsStove, HudCache, Players, RawHands, RawTourneys, Sessions, Settings, Sites, 

8792 Tourneys, TourneysPlayers, TourneyTypes 

8793 """ 

8794 elif db_server == "postgresql": 

8795 self.query["analyze"] = "analyze" 

8796 elif db_server == "sqlite": 

8797 self.query["analyze"] = "analyze" 

8798 

8799 if db_server == "mysql": 

8800 self.query["vacuum"] = """ 

8801 optimize table Actions, Autorates, Backings, Boards, Files, Gametypes, Hands, HandsActions, HandsPlayers,  

8802 HandsStove, HudCache, Players, RawHands, RawTourneys, Sessions, Settings, Sites, 

8803 Tourneys, TourneysPlayers, TourneyTypes 

8804 """ 

8805 elif db_server == "postgresql": 

8806 self.query["vacuum"] = """ vacuum """ 

8807 elif db_server == "sqlite": 

8808 self.query["vacuum"] = """ vacuum """ 

8809 

8810 if db_server == "mysql": 

8811 self.query["switchLockOn"] = """ 

8812 UPDATE InsertLock k1,  

8813 (SELECT count(locked) as locks FROM InsertLock WHERE locked=True) as k2 SET 

8814 k1.locked=%s 

8815 WHERE k1.id=%s 

8816 AND k2.locks = 0""" 

8817 

8818 if db_server == "mysql": 

8819 self.query["switchLockOff"] = """ 

8820 UPDATE InsertLock SET 

8821 locked=%s 

8822 WHERE id=%s""" 

8823 

8824 if db_server == "mysql": 

8825 self.query["lockForInsert"] = """ 

8826 lock tables Hands write, HandsPlayers write, HandsActions write, Players write 

8827 , HudCache write, Gametypes write, Sites write, Tourneys write 

8828 , TourneysPlayers write, TourneyTypes write, Autorates write 

8829 """ 

8830 elif db_server == "postgresql": 

8831 self.query["lockForInsert"] = "" 

8832 elif db_server == "sqlite": 

8833 self.query["lockForInsert"] = "" 

8834 

8835 self.query["getGametypeFL"] = """SELECT id 

8836 FROM Gametypes 

8837 WHERE siteId=%s 

8838 AND type=%s 

8839 AND category=%s 

8840 AND limitType=%s 

8841 AND smallBet=%s 

8842 AND bigBet=%s 

8843 AND maxSeats=%s 

8844 AND ante=%s 

8845 """ # TODO: seems odd to have limitType variable in this query 

8846 

8847 self.query["getGametypeNL"] = """SELECT id 

8848 FROM Gametypes 

8849 WHERE siteId=%s 

8850 AND type=%s 

8851 AND category=%s 

8852 AND limitType=%s 

8853 AND currency=%s 

8854 AND mix=%s 

8855 AND smallBlind=%s 

8856 AND bigBlind=%s 

8857 AND maxSeats=%s 

8858 AND ante=%s 

8859 AND buyinType=%s 

8860 AND fast=%s 

8861 AND newToGame=%s 

8862 AND homeGame=%s 

8863 AND split=%s 

8864 """ # TODO: seems odd to have limitType variable in this query 

8865 

8866 self.query[ 

8867 "insertGameTypes" 

8868 ] = """insert into Gametypes (siteId, currency, type, base, category, limitType, hiLo, mix,  

8869 smallBlind, bigBlind, smallBet, bigBet, maxSeats, ante, buyinType, fast, newToGame, homeGame, split) 

8870 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""" 

8871 

8872 self.query["isAlreadyInDB"] = """SELECT H.id FROM Hands H 

8873 INNER JOIN Gametypes G ON (H.gametypeId = G.id) 

8874 WHERE siteHandNo=%s AND G.siteId=%s<heroSeat> 

8875 """ 

8876 

8877 self.query["getTourneyTypeIdByTourneyNo"] = """SELECT tt.id, 

8878 tt.siteId, 

8879 tt.currency, 

8880 tt.buyin, 

8881 tt.fee, 

8882 tt.category, 

8883 tt.limitType, 

8884 tt.maxSeats, 

8885 tt.sng, 

8886 tt.knockout, 

8887 tt.koBounty, 

8888 tt.progressive, 

8889 tt.rebuy, 

8890 tt.rebuyCost, 

8891 tt.addOn, 

8892 tt.addOnCost, 

8893 tt.speed, 

8894 tt.shootout, 

8895 tt.matrix, 

8896 tt.fast, 

8897 tt.stack,  

8898 tt.step, 

8899 tt.stepNo, 

8900 tt.chance, 

8901 tt.chanceCount, 

8902 tt.multiEntry, 

8903 tt.reEntry, 

8904 tt.homeGame, 

8905 tt.newToGame, 

8906 tt.split, 

8907 tt.fifty50, 

8908 tt.time, 

8909 tt.timeAmt, 

8910 tt.satellite, 

8911 tt.doubleOrNothing, 

8912 tt.cashOut, 

8913 tt.onDemand, 

8914 tt.flighted, 

8915 tt.guarantee, 

8916 tt.guaranteeAmt 

8917 FROM TourneyTypes tt  

8918 INNER JOIN Tourneys t ON (t.tourneyTypeId = tt.id)  

8919 WHERE t.siteTourneyNo=%s AND tt.siteId=%s 

8920 """ 

8921 

8922 self.query["getTourneyTypeId"] = """SELECT id 

8923 FROM TourneyTypes 

8924 WHERE siteId=%s 

8925 AND currency=%s 

8926 AND buyin=%s 

8927 AND fee=%s 

8928 AND category=%s 

8929 AND limitType=%s 

8930 AND maxSeats=%s 

8931 AND sng=%s 

8932 AND knockout=%s 

8933 AND koBounty=%s 

8934 AND progressive=%s 

8935 AND rebuy=%s 

8936 AND rebuyCost=%s 

8937 AND addOn=%s 

8938 AND addOnCost=%s 

8939 AND speed=%s 

8940 AND shootout=%s 

8941 AND matrix=%s 

8942 AND fast=%s 

8943 AND stack=%s 

8944 AND step=%s 

8945 AND stepNo=%s 

8946 AND chance=%s 

8947 AND chanceCount=%s 

8948 AND multiEntry=%s 

8949 AND reEntry=%s 

8950 AND homeGame=%s 

8951 AND newToGame=%s 

8952 AND split=%s 

8953 AND fifty50=%s 

8954 AND time=%s 

8955 AND timeAmt=%s 

8956 AND satellite=%s 

8957 AND doubleOrNothing=%s 

8958 AND cashOut=%s 

8959 AND onDemand=%s 

8960 AND flighted=%s 

8961 AND guarantee=%s 

8962 AND guaranteeAmt=%s 

8963 """ 

8964 

8965 self.query["insertTourneyType"] = """insert into TourneyTypes ( 

8966 siteId, currency, buyin, fee, category, limitType, maxSeats, sng, knockout, koBounty, progressive, 

8967 rebuy, rebuyCost, addOn, addOnCost, speed, shootout, matrix, fast, 

8968 stack, step, stepNo, chance, chanceCount, multiEntry, reEntry, homeGame, newToGame, split, 

8969 fifty50, time, timeAmt, satellite, doubleOrNothing, cashOut, onDemand, flighted, guarantee, guaranteeAmt 

8970 ) 

8971 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 

8972 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) 

8973 """ 

8974 

8975 if db_server == "sqlite": 

8976 self.query["updateTourneyTypeId"] = """UPDATE Tourneys 

8977 SET tourneyTypeId = %s 

8978 WHERE tourneyTypeId in (SELECT id FROM TourneyTypes WHERE siteId=%s) 

8979 AND siteTourneyNo=%s 

8980 """ 

8981 elif db_server == "postgresql": 

8982 self.query["updateTourneyTypeId"] = """UPDATE Tourneys t  

8983 SET tourneyTypeId = %s 

8984 FROM TourneyTypes tt  

8985 WHERE t.tourneyTypeId = tt.id 

8986 AND tt.siteId=%s  

8987 AND t.siteTourneyNo=%s 

8988 """ 

8989 else: 

8990 self.query[ 

8991 "updateTourneyTypeId" 

8992 ] = """UPDATE Tourneys t INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) 

8993 SET tourneyTypeId = %s 

8994 WHERE tt.siteId=%s AND t.siteTourneyNo=%s 

8995 """ 

8996 

8997 self.query["selectTourneyWithTypeId"] = """SELECT id  

8998 FROM Tourneys 

8999 WHERE tourneyTypeId = %s 

9000 """ 

9001 

9002 self.query["deleteTourneyTypeId"] = """DELETE FROM TourneyTypes WHERE id = %s 

9003 """ 

9004 

9005 self.query["getTourneyByTourneyNo"] = """SELECT t.* 

9006 FROM Tourneys t 

9007 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) 

9008 WHERE tt.siteId=%s AND t.siteTourneyNo=%s 

9009 """ 

9010 

9011 self.query["getTourneyInfo"] = """SELECT tt.*, t.* 

9012 FROM Tourneys t 

9013 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) 

9014 INNER JOIN Sites s ON (tt.siteId = s.id) 

9015 WHERE s.name=%s AND t.siteTourneyNo=%s 

9016 """ 

9017 

9018 self.query["getSiteTourneyNos"] = """SELECT t.siteTourneyNo 

9019 FROM Tourneys t 

9020 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) 

9021 INNER JOIN Sites s ON (tt.siteId = s.id) 

9022 WHERE tt.siteId=%s 

9023 """ 

9024 

9025 self.query["getTourneyPlayerInfo"] = """SELECT tp.* 

9026 FROM Tourneys t 

9027 INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) 

9028 INNER JOIN Sites s ON (tt.siteId = s.id) 

9029 INNER JOIN TourneysPlayers tp ON (tp.tourneyId = t.id) 

9030 INNER JOIN Players p ON (p.id = tp.playerId) 

9031 WHERE s.name=%s AND t.siteTourneyNo=%s AND p.name=%s 

9032 """ 

9033 

9034 self.query["insertTourney"] = """insert into Tourneys ( 

9035 tourneyTypeId, sessionId, siteTourneyNo, entries, prizepool, 

9036 startTime, endTime, tourneyName, totalRebuyCount, totalAddOnCount, 

9037 comment, commentTs, added, addedCurrency) 

9038 values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) 

9039 """ 

9040 

9041 self.query["updateTourney"] = """UPDATE Tourneys 

9042 SET entries = %s, 

9043 prizepool = %s, 

9044 startTime = %s, 

9045 endTime = %s, 

9046 tourneyName = %s, 

9047 totalRebuyCount = %s, 

9048 totalAddOnCount = %s, 

9049 comment = %s, 

9050 commentTs = %s, 

9051 added = %s, 

9052 addedCurrency = %s 

9053 WHERE id=%s 

9054 """ 

9055 

9056 self.query["updateTourneyStart"] = """UPDATE Tourneys 

9057 SET startTime = %s 

9058 WHERE id=%s 

9059 """ 

9060 

9061 self.query["updateTourneyEnd"] = """UPDATE Tourneys 

9062 SET endTime = %s 

9063 WHERE id=%s 

9064 """ 

9065 

9066 self.query["getTourneysPlayersByIds"] = """SELECT * 

9067 FROM TourneysPlayers 

9068 WHERE tourneyId=%s AND playerId=%s AND entryId=%s 

9069 """ 

9070 

9071 self.query["getTourneysPlayersByTourney"] = """SELECT playerId, entryId 

9072 FROM TourneysPlayers 

9073 WHERE tourneyId=%s 

9074 """ 

9075 

9076 self.query["updateTourneysPlayer"] = """UPDATE TourneysPlayers 

9077 SET rank = %s, 

9078 winnings = %s, 

9079 winningsCurrency = %s, 

9080 rebuyCount = %s, 

9081 addOnCount = %s, 

9082 koCount = %s 

9083 WHERE id=%s 

9084 """ 

9085 

9086 self.query["updateTourneysPlayerBounties"] = """UPDATE TourneysPlayers 

9087 SET koCount = case when koCount is null then %s else koCount+%s end 

9088 WHERE id=%s 

9089 """ 

9090 

9091 self.query["insertTourneysPlayer"] = """insert into TourneysPlayers ( 

9092 tourneyId, 

9093 playerId, 

9094 entryId, 

9095 rank, 

9096 winnings, 

9097 winningsCurrency, 

9098 rebuyCount, 

9099 addOnCount, 

9100 koCount 

9101 ) 

9102 values (%s, %s, %s, %s, %s,  

9103 %s, %s, %s, %s) 

9104 """ 

9105 

9106 self.query["selectHandsPlayersWithWrongTTypeId"] = """SELECT id 

9107 FROM HandsPlayers  

9108 WHERE tourneyTypeId <> %s AND (TourneysPlayersId+0=%s) 

9109 """ 

9110 

9111 # self.query['updateHandsPlayersForTTypeId2'] = """UPDATE HandsPlayers 

9112 # SET tourneyTypeId= %s 

9113 # WHERE (TourneysPlayersId+0=%s) 

9114 # """ 

9115 

9116 self.query["updateHandsPlayersForTTypeId"] = """UPDATE HandsPlayers  

9117 SET tourneyTypeId= %s 

9118 WHERE (id=%s) 

9119 """ 

9120 

9121 self.query["handsPlayersTTypeId_joiner"] = " OR TourneysPlayersId+0=" 

9122 self.query["handsPlayersTTypeId_joiner_id"] = " OR id=" 

9123 

9124 self.query["store_hand"] = """insert into Hands ( 

9125 tablename, 

9126 sitehandno, 

9127 tourneyId, 

9128 gametypeid, 

9129 sessionId, 

9130 fileId, 

9131 startTime, 

9132 importtime, 

9133 seats, 

9134 heroSeat, 

9135 maxPosition, 

9136 texture, 

9137 playersVpi, 

9138 boardcard1, 

9139 boardcard2, 

9140 boardcard3, 

9141 boardcard4, 

9142 boardcard5, 

9143 runItTwice, 

9144 playersAtStreet1, 

9145 playersAtStreet2, 

9146 playersAtStreet3, 

9147 playersAtStreet4, 

9148 playersAtShowdown, 

9149 street0Raises, 

9150 street1Raises, 

9151 street2Raises, 

9152 street3Raises, 

9153 street4Raises, 

9154 street0Pot, 

9155 street1Pot, 

9156 street2Pot, 

9157 street3Pot, 

9158 street4Pot, 

9159 finalPot 

9160 ) 

9161 values 

9162 (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 

9163 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 

9164 %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 

9165 %s, %s)""" 

9166 

9167 self.query["store_hands_players"] = """insert into HandsPlayers ( 

9168 handId, 

9169 playerId, 

9170 startCash, 

9171 effStack, 

9172 startBounty, 

9173 endBounty, 

9174 seatNo, 

9175 sitout, 

9176 card1, 

9177 card2, 

9178 card3, 

9179 card4, 

9180 card5, 

9181 card6, 

9182 card7, 

9183 card8, 

9184 card9, 

9185 card10, 

9186 card11, 

9187 card12, 

9188 card13, 

9189 card14, 

9190 card15, 

9191 card16, 

9192 card17, 

9193 card18, 

9194 card19, 

9195 card20, 

9196 common, 

9197 committed, 

9198 winnings, 

9199 rake, 

9200 rakeDealt, 

9201 rakeContributed, 

9202 rakeWeighted, 

9203 totalProfit, 

9204 allInEV, 

9205 street0VPIChance, 

9206 street0VPI, 

9207 street1Seen, 

9208 street2Seen, 

9209 street3Seen, 

9210 street4Seen, 

9211 sawShowdown, 

9212 showed, 

9213 street0AllIn, 

9214 street1AllIn, 

9215 street2AllIn, 

9216 street3AllIn, 

9217 street4AllIn, 

9218 wentAllIn, 

9219 street0AggrChance, 

9220 street0Aggr, 

9221 street1Aggr, 

9222 street2Aggr, 

9223 street3Aggr, 

9224 street4Aggr, 

9225 street1CBChance, 

9226 street2CBChance, 

9227 street3CBChance, 

9228 street4CBChance, 

9229 street1CBDone, 

9230 street2CBDone, 

9231 street3CBDone, 

9232 street4CBDone, 

9233 wonWhenSeenStreet1, 

9234 wonWhenSeenStreet2, 

9235 wonWhenSeenStreet3, 

9236 wonWhenSeenStreet4, 

9237 wonAtSD, 

9238 position, 

9239 street0InPosition, 

9240 street1InPosition, 

9241 street2InPosition, 

9242 street3InPosition, 

9243 street4InPosition, 

9244 street0FirstToAct, 

9245 street1FirstToAct, 

9246 street2FirstToAct, 

9247 street3FirstToAct, 

9248 street4FirstToAct, 

9249 tourneysPlayersId, 

9250 startCards, 

9251 street0CalledRaiseChance, 

9252 street0CalledRaiseDone, 

9253 street0_2BChance, 

9254 street0_2BDone, 

9255 street0_3BChance, 

9256 street0_3BDone, 

9257 street0_4BChance, 

9258 street0_4BDone, 

9259 street0_C4BChance, 

9260 street0_C4BDone, 

9261 street0_FoldTo2BChance, 

9262 street0_FoldTo2BDone, 

9263 street0_FoldTo3BChance, 

9264 street0_FoldTo3BDone, 

9265 street0_FoldTo4BChance, 

9266 street0_FoldTo4BDone, 

9267 street0_SqueezeChance, 

9268 street0_SqueezeDone, 

9269 raiseToStealChance, 

9270 raiseToStealDone, 

9271 stealChance, 

9272 stealDone, 

9273 success_Steal, 

9274 otherRaisedStreet0, 

9275 otherRaisedStreet1, 

9276 otherRaisedStreet2, 

9277 otherRaisedStreet3, 

9278 otherRaisedStreet4, 

9279 foldToOtherRaisedStreet0, 

9280 foldToOtherRaisedStreet1, 

9281 foldToOtherRaisedStreet2, 

9282 foldToOtherRaisedStreet3, 

9283 foldToOtherRaisedStreet4, 

9284 raiseFirstInChance, 

9285 raisedFirstIn, 

9286 foldBbToStealChance, 

9287 foldedBbToSteal, 

9288 foldSbToStealChance, 

9289 foldedSbToSteal, 

9290 foldToStreet1CBChance, 

9291 foldToStreet1CBDone, 

9292 foldToStreet2CBChance, 

9293 foldToStreet2CBDone, 

9294 foldToStreet3CBChance, 

9295 foldToStreet3CBDone, 

9296 foldToStreet4CBChance, 

9297 foldToStreet4CBDone, 

9298 street1CheckCallRaiseChance, 

9299 street1CheckCallDone, 

9300 street1CheckRaiseDone, 

9301 street2CheckCallRaiseChance, 

9302 street2CheckCallDone, 

9303 street2CheckRaiseDone, 

9304 street3CheckCallRaiseChance, 

9305 street3CheckCallDone, 

9306 street3CheckRaiseDone, 

9307 street4CheckCallRaiseChance, 

9308 street4CheckCallDone, 

9309 street4CheckRaiseDone, 

9310 street0Calls, 

9311 street1Calls, 

9312 street2Calls, 

9313 street3Calls, 

9314 street4Calls, 

9315 street0Bets, 

9316 street1Bets, 

9317 street2Bets, 

9318 street3Bets, 

9319 street4Bets, 

9320 street0Raises, 

9321 street1Raises, 

9322 street2Raises, 

9323 street3Raises, 

9324 street4Raises, 

9325 street1Discards, 

9326 street2Discards, 

9327 street3Discards, 

9328 handString 

9329 ) 

9330 values ( 

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, %s, %s, %s, %s, 

9350 %s, %s, %s, %s, %s, 

9351 %s, %s, %s, %s, %s, 

9352 %s, %s, %s, %s, %s, 

9353 %s, %s, %s, %s, %s, 

9354 %s, %s, %s, %s, %s, 

9355 %s, %s, %s, %s, %s, 

9356 %s, %s, %s, %s, %s, 

9357 %s, %s, %s, %s, %s, 

9358 %s, %s, %s, %s, %s, 

9359 %s, %s, %s, %s, %s, 

9360 %s, %s, %s, %s, %s, 

9361 %s, %s, %s, %s, %s, 

9362 %s, %s, %s, %s, %s, 

9363 %s 

9364 )""" 

9365 

9366 self.query["store_hands_actions"] = """insert into HandsActions ( 

9367 handId, 

9368 playerId, 

9369 street, 

9370 actionNo, 

9371 streetActionNo, 

9372 actionId, 

9373 amount, 

9374 raiseTo, 

9375 amountCalled, 

9376 numDiscarded, 

9377 cardsDiscarded, 

9378 allIn 

9379 ) 

9380 values ( 

9381 %s, %s, %s, %s, %s, 

9382 %s, %s, %s, %s, %s, 

9383 %s, %s 

9384 )""" 

9385 

9386 self.query["store_hands_stove"] = """insert into HandsStove ( 

9387 handId, 

9388 playerId, 

9389 streetId, 

9390 boardId, 

9391 hiLo, 

9392 rankId, 

9393 value, 

9394 cards, 

9395 ev 

9396 ) 

9397 values ( 

9398 %s, %s, %s, %s, %s, 

9399 %s, %s, %s, %s 

9400 )""" 

9401 

9402 self.query["store_boards"] = """insert into Boards ( 

9403 handId, 

9404 boardId, 

9405 boardcard1, 

9406 boardcard2, 

9407 boardcard3, 

9408 boardcard4, 

9409 boardcard5 

9410 ) 

9411 values ( 

9412 %s, %s, %s, %s, %s, 

9413 %s, %s 

9414 )""" 

9415 

9416 self.query["store_hands_pots"] = """insert into HandsPots ( 

9417 handId, 

9418 potId, 

9419 boardId, 

9420 hiLo, 

9421 playerId, 

9422 pot, 

9423 collected, 

9424 rake 

9425 ) 

9426 values ( 

9427 %s, %s, %s, %s, 

9428 %s, %s, %s, %s 

9429 )""" 

9430 

9431 ################################ 

9432 # queries for Files Table 

9433 ################################ 

9434 

9435 self.query["get_id"] = """ 

9436 SELECT id 

9437 FROM Files 

9438 WHERE file=%s""" 

9439 

9440 self.query["store_file"] = """ insert into Files ( 

9441 file, 

9442 site, 

9443 startTime, 

9444 lastUpdate, 

9445 hands, 

9446 storedHands, 

9447 dups, 

9448 partial, 

9449 skipped, 

9450 errs, 

9451 ttime100, 

9452 finished) 

9453 values ( 

9454 %s, %s, %s, %s, %s, 

9455 %s, %s, %s, %s, %s, 

9456 %s, %s 

9457 )""" 

9458 

9459 self.query["update_file"] = """ 

9460 UPDATE Files SET 

9461 type=%s, 

9462 lastUpdate=%s, 

9463 endTime=%s, 

9464 hands=hands+%s, 

9465 storedHands=storedHands+%s, 

9466 dups=dups+%s, 

9467 partial=partial+%s, 

9468 skipped=skipped+%s, 

9469 errs=errs+%s, 

9470 ttime100=ttime100+%s, 

9471 finished=%s 

9472 WHERE id=%s""" 

9473 

9474 ################################ 

9475 # Counts for DB stats window 

9476 ################################ 

9477 self.query["getHandCount"] = "SELECT COUNT(*) FROM Hands" 

9478 self.query["getTourneyCount"] = "SELECT COUNT(*) FROM Tourneys" 

9479 self.query["getTourneyTypeCount"] = "SELECT COUNT(*) FROM TourneyTypes" 

9480 

9481 ################################ 

9482 # queries for dumpDatabase 

9483 ################################ 

9484 for table in ( 

9485 "Autorates", 

9486 "Backings", 

9487 "Gametypes", 

9488 "Hands", 

9489 "HandsActions", 

9490 "HandsPlayers", 

9491 "HudCache", 

9492 "Players", 

9493 "RawHands", 

9494 "RawTourneys", 

9495 "Settings", 

9496 "Sites", 

9497 "TourneyTypes", 

9498 "Tourneys", 

9499 "TourneysPlayers", 

9500 ): 

9501 self.query["get" + table] = "SELECT * FROM " + table 

9502 

9503 ################################ 

9504 # placeholders and substitution stuff 

9505 ################################ 

9506 if db_server == "mysql": 

9507 self.query["placeholder"] = "%s" 

9508 elif db_server == "postgresql": 

9509 self.query["placeholder"] = "%s" 

9510 elif db_server == "sqlite": 

9511 self.query["placeholder"] = "?" 

9512 

9513 # If using sqlite, use the ? placeholder instead of %s 

9514 if db_server == "sqlite": 

9515 for k, q in list(self.query.items()): 

9516 self.query[k] = re.sub("%s", "?", q) 

9517 

9518 

9519if __name__ == "__main__": 

9520 # just print the default queries and exit 

9521 s = Sql() 

9522 for key in s.query: 

9523 print("For query " + key + ", sql =") 

9524 print(s.query[key])