add new tables RawHands/RawTourneys

This commit is contained in:
steffen123 2010-08-21 04:29:29 +02:00
parent 62ad7bcdb7
commit 6474f92dd1
2 changed files with 55 additions and 6 deletions

View File

@ -82,7 +82,7 @@ except ImportError:
use_numpy = False use_numpy = False
DB_VERSION = 142 DB_VERSION = 143
# Variance created as sqlite has a bunch of undefined aggregate functions. # Variance created as sqlite has a bunch of undefined aggregate functions.
@ -150,6 +150,8 @@ class Database:
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0} , {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
, {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0} , {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0}
, {'tab':'Backings', 'col':'playerId', 'drop':0} , {'tab':'Backings', 'col':'playerId', 'drop':0}
, {'tab':'RawHands', 'col':'id', 'drop':0}
, {'tab':'RawTourneys', 'col':'id', 'drop':0}
] ]
, [ # indexes for sqlite (list index 4) , [ # indexes for sqlite (list index 4)
{'tab':'Hands', 'col':'gametypeId', 'drop':0} {'tab':'Hands', 'col':'gametypeId', 'drop':0}
@ -165,6 +167,8 @@ class Database:
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0} , {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
, {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0} , {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0}
, {'tab':'Backings', 'col':'playerId', 'drop':0} , {'tab':'Backings', 'col':'playerId', 'drop':0}
, {'tab':'RawHands', 'col':'id', 'drop':0}
, {'tab':'RawTourneys', 'col':'id', 'drop':0}
] ]
] ]
@ -306,9 +310,7 @@ class Database:
tables=self.cursor.execute(self.sql.query['list_tables']) tables=self.cursor.execute(self.sql.query['list_tables'])
tables=self.cursor.fetchall() tables=self.cursor.fetchall()
for table in tables: for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
table=table[0]
print "table:", table print "table:", table
result+="###################\nTable "+table+"\n###################\n" result+="###################\nTable "+table+"\n###################\n"
rows=self.cursor.execute(self.sql.query['get'+table]) rows=self.cursor.execute(self.sql.query['get'+table])
@ -1155,6 +1157,8 @@ class Database:
c.execute(self.sql.query['createHandsActionsTable']) c.execute(self.sql.query['createHandsActionsTable'])
c.execute(self.sql.query['createHudCacheTable']) c.execute(self.sql.query['createHudCacheTable'])
c.execute(self.sql.query['createBackingsTable']) c.execute(self.sql.query['createBackingsTable'])
c.execute(self.sql.query['createRawHands'])
c.execute(self.sql.query['createRawTourneys'])
# Create unique indexes: # Create unique indexes:
log.debug("Creating unique indexes") log.debug("Creating unique indexes")

View File

@ -108,7 +108,52 @@ class Sql:
self.query['createSettingsTable'] = """CREATE TABLE Settings self.query['createSettingsTable'] = """CREATE TABLE Settings
(version INTEGER NOT NULL) """ (version INTEGER NOT NULL) """
################################
# Create RawHands (this table is all but identical with RawTourneys)
################################
if db_server == 'mysql':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id BIGSERIAL, PRIMARY KEY (id),
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
elif db_server == 'sqlite':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id INTEGER PRIMARY KEY,
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
################################
# Create RawTourneys (this table is all but identical with RawHands)
################################
if db_server == 'mysql':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id BIGSERIAL, PRIMARY KEY (id),
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
elif db_server == 'sqlite':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id INTEGER PRIMARY KEY,
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
################################ ################################
# Create Sites # Create Sites
################################ ################################
@ -4182,7 +4227,7 @@ class Sql:
################################ ################################
# queries for dumpDatabase # queries for dumpDatabase
################################ ################################
for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'): for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
self.query['get'+table] = u"SELECT * FROM "+table self.query['get'+table] = u"SELECT * FROM "+table
################################ ################################