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)
|
||||
# (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
|
||||
# FROM INFORMATION_SCHEMA.STATISTICS
|
||||
# WHERE table_name = 'tbl_name'
|
||||
|
@ -223,6 +223,7 @@ class Database:
|
|||
# Note: index names must be unique across a schema
|
||||
# CREATE INDEX idx ON tab(col)
|
||||
# DROP INDEX idx
|
||||
# SELECT * FROM PG_INDEXES
|
||||
|
||||
# SQLite notes:
|
||||
|
||||
|
@ -1075,7 +1076,7 @@ class Database:
|
|||
c = self.get_cursor()
|
||||
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['createGametypesTable'])
|
||||
c.execute(self.sql.query['createPlayersTable'])
|
||||
|
@ -1088,7 +1089,8 @@ class Database:
|
|||
c.execute(self.sql.query['createHandsActionsTable'])
|
||||
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['addHandsIndex'])
|
||||
c.execute(self.sql.query['addPlayersIndex'])
|
||||
|
@ -1162,7 +1164,8 @@ class Database:
|
|||
self.connection.set_isolation_level(0) # allow table/index operations to work
|
||||
for idx in self.indexes[self.backend]:
|
||||
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:
|
||||
s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
|
@ -1170,21 +1173,23 @@ 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 ", 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:
|
||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
except:
|
||||
print " create idx failed: " + str(sys.exc_info())
|
||||
elif self.backend == self.SQLITE:
|
||||
log.debug("Creating sqlite index %s %s" % (idx['tab'], idx['col']))
|
||||
print "Creating sqlite index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating sqlite 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)
|
||||
except:
|
||||
log.debug("Create idx failed: " + str(sys.exc_info()))
|
||||
else:
|
||||
print "Only MySQL, Postgres and SQLite supported so far"
|
||||
print "Unknown database: MySQL, Postgres and SQLite supported"
|
||||
return -1
|
||||
if self.backend == self.PGSQL:
|
||||
self.connection.set_isolation_level(1) # go back to normal isolation level
|
||||
|
@ -1215,8 +1220,15 @@ class Database:
|
|||
% (idx['tab'],idx['col']) )
|
||||
except:
|
||||
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:
|
||||
print "Only MySQL and Postgres supported so far"
|
||||
print "Only MySQL, Postgres and SQLITE supported, what are you trying to use?"
|
||||
return -1
|
||||
if self.backend == self.PGSQL:
|
||||
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())
|
||||
log.debug("markStreets:\n"+ str(self.streets))
|
||||
else:
|
||||
tmp = self.handText[0:100]
|
||||
log.error("markstreets didn't match")
|
||||
log.error(" - Assuming hand cancelled")
|
||||
self.cancelled = True
|
||||
raise FpdbParseError
|
||||
raise FpdbParseError("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'" % tmp)
|
||||
|
||||
def checkPlayerExists(self,player):
|
||||
if player not in [p[1] for p in self.players]:
|
||||
print "checkPlayerExists", player, "fail"
|
||||
raise FpdbParseError
|
||||
print "DEBUG: checkPlayerExists %s fail" % player
|
||||
raise FpdbParseError("checkPlayerExists: '%s' failed." % player)
|
||||
|
||||
|
||||
|
||||
|
@ -1487,9 +1488,9 @@ class Pot(object):
|
|||
if self.sym is None:
|
||||
self.sym = "C"
|
||||
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.
|
||||
raise FpdbParseError
|
||||
raise FpdbParseError("FpdbError in printing Hand object")
|
||||
|
||||
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
||||
if len(self.pots) < 2:
|
||||
|
|
|
@ -137,8 +137,7 @@ Otherwise, finish at EOF.
|
|||
self.numHands += 1
|
||||
except FpdbParseError, e:
|
||||
self.numErrors += 1
|
||||
log.warning("Failed to convert hand %s" % e.hid)
|
||||
log.warning("Exception msg: '%s'" % str(e))
|
||||
log.warning("HHC.start(follow): processHand failed: Exception msg: '%s'" % e)
|
||||
log.debug(handText)
|
||||
else:
|
||||
handsList = self.allHandsAsList()
|
||||
|
@ -152,8 +151,7 @@ Otherwise, finish at EOF.
|
|||
self.processedHands.append(self.processHand(handText))
|
||||
except FpdbParseError, e:
|
||||
self.numErrors += 1
|
||||
log.warning("Failed to convert hand %s" % e.hid)
|
||||
log.warning("Exception msg: '%s'" % str(e))
|
||||
log.warning("HHC.start(): processHand failed: Exception msg: '%s'" % e)
|
||||
log.debug(handText)
|
||||
self.numHands = len(handsList)
|
||||
endtime = time.time()
|
||||
|
|
|
@ -140,7 +140,7 @@ class PokerStars(HandHistoryConverter):
|
|||
tmp = handText[0:100]
|
||||
log.error("determineGameType: Unable to recognise gametype from: '%s'" % tmp)
|
||||
log.error("determineGameType: Raising FpdbParseError")
|
||||
raise FpdbParseError
|
||||
raise FpdbParseError("Unable to recognise gametype from: '%s'" % tmp)
|
||||
|
||||
mg = m.groupdict()
|
||||
# translations from captured groups to fpdb info strings
|
||||
|
@ -194,7 +194,7 @@ class PokerStars(HandHistoryConverter):
|
|||
except KeyError:
|
||||
log.error("determineGameType: Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
||||
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.
|
||||
return info
|
||||
|
|
|
@ -51,6 +51,18 @@ class Sql:
|
|||
WHERE type='table'
|
||||
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
|
||||
##################################################################
|
||||
|
|
|
@ -110,7 +110,7 @@ import Database
|
|||
import Configuration
|
||||
import Exceptions
|
||||
|
||||
VERSION = "0.12"
|
||||
VERSION = "0.20"
|
||||
|
||||
|
||||
class fpdb:
|
||||
|
|
Loading…
Reference in New Issue
Block a user