add tourneyid to hands table (REQUIRES REIMPORT) and fix sqlite db access
This commit is contained in:
parent
de2b807c9b
commit
47baee65f9
|
@ -1286,6 +1286,7 @@ class Database:
|
||||||
p['tableName'],
|
p['tableName'],
|
||||||
p['gameTypeId'],
|
p['gameTypeId'],
|
||||||
p['siteHandNo'],
|
p['siteHandNo'],
|
||||||
|
0, # tourneyId: 0 means not a tourney hand
|
||||||
p['handStart'],
|
p['handStart'],
|
||||||
datetime.today(), #importtime
|
datetime.today(), #importtime
|
||||||
p['seats'],
|
p['seats'],
|
||||||
|
|
|
@ -214,6 +214,7 @@ class Sql:
|
||||||
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||||
tableName VARCHAR(22) NOT NULL,
|
tableName VARCHAR(22) NOT NULL,
|
||||||
siteHandNo BIGINT NOT NULL,
|
siteHandNo BIGINT NOT NULL,
|
||||||
|
tourneyId INT UNSIGNED NOT NULL,
|
||||||
gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||||
handStart DATETIME NOT NULL,
|
handStart DATETIME NOT NULL,
|
||||||
importTime DATETIME NOT NULL,
|
importTime DATETIME NOT NULL,
|
||||||
|
@ -249,6 +250,7 @@ class Sql:
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
tableName VARCHAR(22) NOT NULL,
|
tableName VARCHAR(22) NOT NULL,
|
||||||
siteHandNo BIGINT NOT NULL,
|
siteHandNo BIGINT NOT NULL,
|
||||||
|
tourneyId INT NOT NULL,
|
||||||
gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||||
handStart timestamp without time zone NOT NULL,
|
handStart timestamp without time zone NOT NULL,
|
||||||
importTime timestamp without time zone NOT NULL,
|
importTime timestamp without time zone NOT NULL,
|
||||||
|
@ -283,6 +285,7 @@ class Sql:
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
tableName TEXT(22) NOT NULL,
|
tableName TEXT(22) NOT NULL,
|
||||||
siteHandNo INT NOT NULL,
|
siteHandNo INT NOT NULL,
|
||||||
|
tourneyId INT NOT NULL,
|
||||||
gametypeId INT NOT NULL,
|
gametypeId INT NOT NULL,
|
||||||
handStart REAL NOT NULL,
|
handStart REAL NOT NULL,
|
||||||
importTime REAL NOT NULL,
|
importTime REAL NOT NULL,
|
||||||
|
@ -3437,6 +3440,7 @@ class Sql:
|
||||||
tablename,
|
tablename,
|
||||||
gametypeid,
|
gametypeid,
|
||||||
sitehandno,
|
sitehandno,
|
||||||
|
tourneyId,
|
||||||
handstart,
|
handstart,
|
||||||
importtime,
|
importtime,
|
||||||
seats,
|
seats,
|
||||||
|
@ -3467,7 +3471,7 @@ class Sql:
|
||||||
VALUES
|
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, %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 (
|
self.query['store_hands_players'] = """INSERT INTO HandsPlayers (
|
||||||
|
|
|
@ -154,19 +154,21 @@ class fpdb_db:
|
||||||
print msg
|
print msg
|
||||||
raise FpdbError(msg)
|
raise FpdbError(msg)
|
||||||
elif backend == fpdb_db.SQLITE:
|
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
|
import sqlite3
|
||||||
if use_pool:
|
if use_pool:
|
||||||
sqlite3 = pool.manage(sqlite3, pool_size=1)
|
sqlite3 = pool.manage(sqlite3, pool_size=1)
|
||||||
else:
|
else:
|
||||||
logging.warning("SQLite won't work well without 'sqlalchemy' installed.")
|
logging.warning("SQLite won't work well without 'sqlalchemy' installed.")
|
||||||
|
|
||||||
if not os.path.isdir(self.config.dir_databases) and not database == ":memory:":
|
if database != ":memory:":
|
||||||
print "Creating directory: '%s'" % (self.config.dir_databases)
|
if not os.path.isdir(self.config.dir_databases):
|
||||||
logging.info("Creating directory: '%s'" % (self.config.dir_databases))
|
print "Creating directory: '%s'" % (self.config.dir_databases)
|
||||||
os.mkdir(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)
|
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 )
|
self.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
|
||||||
sqlite3.register_converter("bool", lambda x: bool(int(x)))
|
sqlite3.register_converter("bool", lambda x: bool(int(x)))
|
||||||
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
|
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user