diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 7194b230..c24d13fb 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -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'], diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 5913c624..5ff4c8e6 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -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 ( diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index 514823af..bdbf430c 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -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")