Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
d56d3009b6
|
@ -193,7 +193,7 @@ class Database:
|
||||||
# alter table t add constraint c foreign key (fkcol) references tab(rcol)
|
# alter table t add constraint c foreign key (fkcol) references tab(rcol)
|
||||||
# (fkcol is used for foreigh key name)
|
# (fkcol is used for foreigh key name)
|
||||||
|
|
||||||
# mysql to list indexes:
|
# mysql to list indexes: (CG - "LIST INDEXES" should work too)
|
||||||
# SELECT table_name, index_name, non_unique, column_name
|
# SELECT table_name, index_name, non_unique, column_name
|
||||||
# FROM INFORMATION_SCHEMA.STATISTICS
|
# FROM INFORMATION_SCHEMA.STATISTICS
|
||||||
# WHERE table_name = 'tbl_name'
|
# WHERE table_name = 'tbl_name'
|
||||||
|
@ -223,6 +223,7 @@ class Database:
|
||||||
# Note: index names must be unique across a schema
|
# Note: index names must be unique across a schema
|
||||||
# CREATE INDEX idx ON tab(col)
|
# CREATE INDEX idx ON tab(col)
|
||||||
# DROP INDEX idx
|
# DROP INDEX idx
|
||||||
|
# SELECT * FROM PG_INDEXES
|
||||||
|
|
||||||
# SQLite notes:
|
# SQLite notes:
|
||||||
|
|
||||||
|
@ -1075,7 +1076,7 @@ class Database:
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
c.execute(self.sql.query['createSettingsTable'])
|
c.execute(self.sql.query['createSettingsTable'])
|
||||||
|
|
||||||
log.debug(self.sql.query['createSitesTable'])
|
log.debug("Creating tables")
|
||||||
c.execute(self.sql.query['createSitesTable'])
|
c.execute(self.sql.query['createSitesTable'])
|
||||||
c.execute(self.sql.query['createGametypesTable'])
|
c.execute(self.sql.query['createGametypesTable'])
|
||||||
c.execute(self.sql.query['createPlayersTable'])
|
c.execute(self.sql.query['createPlayersTable'])
|
||||||
|
@ -1088,7 +1089,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'])
|
||||||
|
|
||||||
# create unique indexes:
|
# Create unique indexes:
|
||||||
|
log.debug("Creating unique indexes")
|
||||||
c.execute(self.sql.query['addTourneyIndex'])
|
c.execute(self.sql.query['addTourneyIndex'])
|
||||||
c.execute(self.sql.query['addHandsIndex'])
|
c.execute(self.sql.query['addHandsIndex'])
|
||||||
c.execute(self.sql.query['addPlayersIndex'])
|
c.execute(self.sql.query['addPlayersIndex'])
|
||||||
|
@ -1162,7 +1164,8 @@ class Database:
|
||||||
self.connection.set_isolation_level(0) # allow table/index operations to work
|
self.connection.set_isolation_level(0) # allow table/index operations to work
|
||||||
for idx in self.indexes[self.backend]:
|
for idx in self.indexes[self.backend]:
|
||||||
if self.backend == self.MYSQL_INNODB:
|
if self.backend == self.MYSQL_INNODB:
|
||||||
print "creating mysql index ", idx['tab'], idx['col']
|
print "Creating mysql index %s %s" %(idx['tab'], idx['col'])
|
||||||
|
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||||
try:
|
try:
|
||||||
s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
|
s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
|
||||||
self.get_cursor().execute(s)
|
self.get_cursor().execute(s)
|
||||||
|
@ -1170,13 +1173,15 @@ class Database:
|
||||||
print " create idx failed: " + str(sys.exc_info())
|
print " create idx failed: " + str(sys.exc_info())
|
||||||
elif self.backend == self.PGSQL:
|
elif self.backend == self.PGSQL:
|
||||||
# mod to use tab_col for index name?
|
# mod to use tab_col for index name?
|
||||||
print "creating pg index ", idx['tab'], idx['col']
|
print "Creating pg index %s %s" %(idx['tab'], idx['col'])
|
||||||
|
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||||
try:
|
try:
|
||||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||||
self.get_cursor().execute(s)
|
self.get_cursor().execute(s)
|
||||||
except:
|
except:
|
||||||
print " create idx failed: " + str(sys.exc_info())
|
print " create idx failed: " + str(sys.exc_info())
|
||||||
elif self.backend == self.SQLITE:
|
elif self.backend == self.SQLITE:
|
||||||
|
print "Creating sqlite index %s %s" %(idx['tab'], idx['col'])
|
||||||
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||||
try:
|
try:
|
||||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||||
|
@ -1184,7 +1189,7 @@ class Database:
|
||||||
except:
|
except:
|
||||||
log.debug("Create idx failed: " + str(sys.exc_info()))
|
log.debug("Create idx failed: " + str(sys.exc_info()))
|
||||||
else:
|
else:
|
||||||
print "Only MySQL, Postgres and SQLite supported so far"
|
print "Unknown database: MySQL, Postgres and SQLite supported"
|
||||||
return -1
|
return -1
|
||||||
if self.backend == self.PGSQL:
|
if self.backend == self.PGSQL:
|
||||||
self.connection.set_isolation_level(1) # go back to normal isolation level
|
self.connection.set_isolation_level(1) # go back to normal isolation level
|
||||||
|
@ -1215,8 +1220,15 @@ class Database:
|
||||||
% (idx['tab'],idx['col']) )
|
% (idx['tab'],idx['col']) )
|
||||||
except:
|
except:
|
||||||
print " drop idx failed: " + str(sys.exc_info())
|
print " drop idx failed: " + str(sys.exc_info())
|
||||||
|
elif self.backend == self.SQLITE:
|
||||||
|
print "Dropping sqlite index ", idx['tab'], idx['col']
|
||||||
|
try:
|
||||||
|
self.get_cursor().execute( "drop index %s_%s_idx"
|
||||||
|
% (idx['tab'],idx['col']) )
|
||||||
|
except:
|
||||||
|
print " drop idx failed: " + str(sys.exc_info())
|
||||||
else:
|
else:
|
||||||
print "Only MySQL and Postgres supported so far"
|
print "Only MySQL, Postgres and SQLITE supported, what are you trying to use?"
|
||||||
return -1
|
return -1
|
||||||
if self.backend == self.PGSQL:
|
if self.backend == self.PGSQL:
|
||||||
self.connection.set_isolation_level(1) # go back to normal isolation level
|
self.connection.set_isolation_level(1) # go back to normal isolation level
|
||||||
|
|
|
@ -274,15 +274,16 @@ If a player has None chips he won't be added."""
|
||||||
self.streets.update(match.groupdict())
|
self.streets.update(match.groupdict())
|
||||||
log.debug("markStreets:\n"+ str(self.streets))
|
log.debug("markStreets:\n"+ str(self.streets))
|
||||||
else:
|
else:
|
||||||
|
tmp = self.handText[0:100]
|
||||||
log.error("markstreets didn't match")
|
log.error("markstreets didn't match")
|
||||||
log.error(" - Assuming hand cancelled")
|
log.error(" - Assuming hand cancelled")
|
||||||
self.cancelled = True
|
self.cancelled = True
|
||||||
raise FpdbParseError
|
raise FpdbParseError("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'" % tmp)
|
||||||
|
|
||||||
def checkPlayerExists(self,player):
|
def checkPlayerExists(self,player):
|
||||||
if player not in [p[1] for p in self.players]:
|
if player not in [p[1] for p in self.players]:
|
||||||
print "checkPlayerExists", player, "fail"
|
print "DEBUG: checkPlayerExists %s fail" % player
|
||||||
raise FpdbParseError
|
raise FpdbParseError("checkPlayerExists: '%s' failed." % player)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1487,9 +1488,9 @@ class Pot(object):
|
||||||
if self.sym is None:
|
if self.sym is None:
|
||||||
self.sym = "C"
|
self.sym = "C"
|
||||||
if self.total is None:
|
if self.total is None:
|
||||||
print "call Pot.end() before printing pot total"
|
print "DEBUG: call Pot.end() before printing pot total"
|
||||||
# NB if I'm sure end() is idempotent, call it here.
|
# NB if I'm sure end() is idempotent, call it here.
|
||||||
raise FpdbParseError
|
raise FpdbParseError("FpdbError in printing Hand object")
|
||||||
|
|
||||||
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
||||||
if len(self.pots) < 2:
|
if len(self.pots) < 2:
|
||||||
|
|
|
@ -137,8 +137,7 @@ Otherwise, finish at EOF.
|
||||||
self.numHands += 1
|
self.numHands += 1
|
||||||
except FpdbParseError, e:
|
except FpdbParseError, e:
|
||||||
self.numErrors += 1
|
self.numErrors += 1
|
||||||
log.warning("Failed to convert hand %s" % e.hid)
|
log.warning("HHC.start(follow): processHand failed: Exception msg: '%s'" % e)
|
||||||
log.warning("Exception msg: '%s'" % str(e))
|
|
||||||
log.debug(handText)
|
log.debug(handText)
|
||||||
else:
|
else:
|
||||||
handsList = self.allHandsAsList()
|
handsList = self.allHandsAsList()
|
||||||
|
@ -152,8 +151,7 @@ Otherwise, finish at EOF.
|
||||||
self.processedHands.append(self.processHand(handText))
|
self.processedHands.append(self.processHand(handText))
|
||||||
except FpdbParseError, e:
|
except FpdbParseError, e:
|
||||||
self.numErrors += 1
|
self.numErrors += 1
|
||||||
log.warning("Failed to convert hand %s" % e.hid)
|
log.warning("HHC.start(): processHand failed: Exception msg: '%s'" % e)
|
||||||
log.warning("Exception msg: '%s'" % str(e))
|
|
||||||
log.debug(handText)
|
log.debug(handText)
|
||||||
self.numHands = len(handsList)
|
self.numHands = len(handsList)
|
||||||
endtime = time.time()
|
endtime = time.time()
|
||||||
|
|
|
@ -140,7 +140,7 @@ class PokerStars(HandHistoryConverter):
|
||||||
tmp = handText[0:100]
|
tmp = handText[0:100]
|
||||||
log.error("determineGameType: Unable to recognise gametype from: '%s'" % tmp)
|
log.error("determineGameType: Unable to recognise gametype from: '%s'" % tmp)
|
||||||
log.error("determineGameType: Raising FpdbParseError")
|
log.error("determineGameType: Raising FpdbParseError")
|
||||||
raise FpdbParseError
|
raise FpdbParseError("Unable to recognise gametype from: '%s'" % tmp)
|
||||||
|
|
||||||
mg = m.groupdict()
|
mg = m.groupdict()
|
||||||
# translations from captured groups to fpdb info strings
|
# translations from captured groups to fpdb info strings
|
||||||
|
@ -194,7 +194,7 @@ class PokerStars(HandHistoryConverter):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.error("determineGameType: Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
log.error("determineGameType: Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
||||||
log.error("determineGameType: Raising FpdbParseError")
|
log.error("determineGameType: Raising FpdbParseError")
|
||||||
raise FpdbParseError
|
raise FpdbParseError("Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
||||||
|
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
return info
|
return info
|
||||||
|
|
|
@ -51,6 +51,18 @@ class Sql:
|
||||||
WHERE type='table'
|
WHERE type='table'
|
||||||
ORDER BY name;"""
|
ORDER BY name;"""
|
||||||
|
|
||||||
|
################################
|
||||||
|
# List indexes
|
||||||
|
################################
|
||||||
|
if db_server == 'mysql':
|
||||||
|
self.query['list_tables'] = """SHOW INDEXES"""
|
||||||
|
elif db_server == 'postgresql':
|
||||||
|
self.query['list_tables'] = """SELECT tablename, indexname FROM PG_INDEXES"""
|
||||||
|
elif db_server == 'sqlite':
|
||||||
|
self.query['list_tables'] = """SELECT name FROM sqlite_master
|
||||||
|
WHERE type='index'
|
||||||
|
ORDER BY name;"""
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
# Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax
|
# Drop Tables - MySQL, PostgreSQL and SQLite all share same syntax
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
|
@ -110,7 +110,7 @@ import Database
|
||||||
import Configuration
|
import Configuration
|
||||||
import Exceptions
|
import Exceptions
|
||||||
|
|
||||||
VERSION = "0.12"
|
VERSION = "0.20"
|
||||||
|
|
||||||
|
|
||||||
class fpdb:
|
class fpdb:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user