DB: add backings table, fix a couple of log entries
This commit is contained in:
parent
9283d7b579
commit
d53b3e1b4a
|
@ -74,7 +74,7 @@ except ImportError:
|
|||
use_numpy = False
|
||||
|
||||
|
||||
DB_VERSION = 130
|
||||
DB_VERSION = 131
|
||||
|
||||
|
||||
# Variance created as sqlite has a bunch of undefined aggregate functions.
|
||||
|
@ -140,6 +140,8 @@ class Database:
|
|||
, {'tab':'TourneysPlayers', 'col':'playerId', 'drop':0}
|
||||
#, {'tab':'TourneysPlayers', 'col':'tourneyId', 'drop':0} unique indexes not dropped
|
||||
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'tourneysPlayerId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'playerId', 'drop':0}
|
||||
]
|
||||
, [ # indexes for sqlite (list index 4)
|
||||
{'tab':'Hands', 'col':'gametypeId', 'drop':0}
|
||||
|
@ -154,6 +156,8 @@ class Database:
|
|||
, {'tab':'Tourneys', 'col':'tourneyTypeId', 'drop':1}
|
||||
, {'tab':'TourneysPlayers', 'col':'playerId', 'drop':0}
|
||||
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'tourneysPlayerId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'playerId', 'drop':0}
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -1135,6 +1139,7 @@ class Database:
|
|||
c.execute(self.sql.query['createHandsPlayersTable'])
|
||||
c.execute(self.sql.query['createHandsActionsTable'])
|
||||
c.execute(self.sql.query['createHudCacheTable'])
|
||||
c.execute(self.sql.query['createBackingsTable'])
|
||||
|
||||
# Create unique indexes:
|
||||
log.debug("Creating unique indexes")
|
||||
|
@ -1212,7 +1217,7 @@ class Database:
|
|||
for idx in self.indexes[self.backend]:
|
||||
if self.backend == self.MYSQL_INNODB:
|
||||
print "Creating mysql index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||
log.debug("Creating mysql index %s %s" %(idx['tab'], idx['col']))
|
||||
try:
|
||||
s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
|
@ -1220,8 +1225,8 @@ class Database:
|
|||
print " create idx failed: " + str(sys.exc_info())
|
||||
elif self.backend == self.PGSQL:
|
||||
# mod to use tab_col for index name?
|
||||
print "Creating pg index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||
print "Creating pgsql index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating pgsql index %s %s" %(idx['tab'], idx['col']))
|
||||
try:
|
||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
|
|
|
@ -130,7 +130,32 @@ class Sql:
|
|||
name TEXT NOT NULL,
|
||||
code TEXT NOT NULL)"""
|
||||
|
||||
|
||||
################################
|
||||
# Create Backings
|
||||
################################
|
||||
|
||||
if db_server == 'mysql':
|
||||
self.query['createBackingsTable'] = """CREATE TABLE Backings (
|
||||
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||
tourneysPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (tourneysPlayerId) REFERENCES TourneysPlayers(id),
|
||||
playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
buyInPercentage FLOAT UNSIGNED NOT NULL,
|
||||
payOffPercentage FLOAT UNSIGNED NOT NULL) ENGINE=INNODB"""
|
||||
elif db_server == 'postgresql':
|
||||
self.query['createBackingsTable'] = """CREATE TABLE Backings (
|
||||
id BIGSERIAL, PRIMARY KEY (id),
|
||||
tourneysPlayerId INT NOT NULL, FOREIGN KEY (tourneysPlayerId) REFERENCES TourneysPlayers(id),
|
||||
playerId INT NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||
buyInPercentage FLOAT UNSIGNED NOT NULL,
|
||||
payOffPercentage FLOAT UNSIGNED NOT NULL)"""
|
||||
elif db_server == 'sqlite':
|
||||
self.query['createBackingsTable'] = """CREATE TABLE Backings (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tourneysPlayerId INT NOT NULL,
|
||||
playerId INT NOT NULL,
|
||||
buyInPercentage REAL UNSIGNED NOT NULL,
|
||||
payOffPercentage REAL UNSIGNED NOT NULL)"""
|
||||
|
||||
################################
|
||||
# Create Gametypes
|
||||
################################
|
||||
|
|
Loading…
Reference in New Issue
Block a user