add tourneyid to hands table (REQUIRES REIMPORT) and fix sqlite db access

This commit is contained in:
sqlcoder 2010-01-26 22:46:48 +00:00
parent de2b807c9b
commit 47baee65f9
3 changed files with 14 additions and 7 deletions

View File

@ -1286,6 +1286,7 @@ class Database:
p['tableName'],
p['gameTypeId'],
p['siteHandNo'],
0, # tourneyId: 0 means not a tourney hand
p['handStart'],
datetime.today(), #importtime
p['seats'],

View File

@ -214,6 +214,7 @@ class Sql:
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
tableName VARCHAR(22) NOT NULL,
siteHandNo BIGINT NOT NULL,
tourneyId INT UNSIGNED NOT NULL,
gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
handStart DATETIME NOT NULL,
importTime DATETIME NOT NULL,
@ -249,6 +250,7 @@ class Sql:
id BIGSERIAL, PRIMARY KEY (id),
tableName VARCHAR(22) NOT NULL,
siteHandNo BIGINT NOT NULL,
tourneyId INT NOT NULL,
gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
handStart timestamp without time zone NOT NULL,
importTime timestamp without time zone NOT NULL,
@ -283,6 +285,7 @@ class Sql:
id INTEGER PRIMARY KEY,
tableName TEXT(22) NOT NULL,
siteHandNo INT NOT NULL,
tourneyId INT NOT NULL,
gametypeId INT NOT NULL,
handStart REAL NOT NULL,
importTime REAL NOT NULL,
@ -3437,6 +3440,7 @@ class Sql:
tablename,
gametypeid,
sitehandno,
tourneyId,
handstart,
importtime,
seats,
@ -3467,7 +3471,7 @@ class Sql:
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
self.query['store_hands_players'] = """INSERT INTO HandsPlayers (

View File

@ -154,19 +154,21 @@ class fpdb_db:
print msg
raise FpdbError(msg)
elif backend == fpdb_db.SQLITE:
logging.info("Connecting to SQLite:%(database)s" % {'database':database})
logging.info("Connecting to SQLite: %(database)s" % {'database':database})
import sqlite3
if use_pool:
sqlite3 = pool.manage(sqlite3, pool_size=1)
else:
logging.warning("SQLite won't work well without 'sqlalchemy' installed.")
if not os.path.isdir(self.config.dir_databases) and not database == ":memory:":
print "Creating directory: '%s'" % (self.config.dir_databases)
logging.info("Creating directory: '%s'" % (self.config.dir_databases))
os.mkdir(self.config.dir_databases)
if database != ":memory:":
if not os.path.isdir(self.config.dir_databases):
print "Creating directory: '%s'" % (self.config.dir_databases)
logging.info("Creating directory: '%s'" % (self.config.dir_databases))
os.mkdir(self.config.dir_databases)
createTables = True # not needed? just test for no settings table
database = os.path.join(self.config.dir_databases, database)
createTables = True
logging.info(" sqlite db: " + database)
self.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
sqlite3.register_converter("bool", lambda x: bool(int(x)))
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")