From c519756a49dbc9f4cb65bd84f2103fa8926c3820 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Fri, 25 Sep 2009 20:18:13 +0100 Subject: [PATCH] look for sqlite db in 'database' dir, create dir first if required --- pyfpdb/fpdb_db.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py index 1e74865e..e67a071f 100644 --- a/pyfpdb/fpdb_db.py +++ b/pyfpdb/fpdb_db.py @@ -39,6 +39,8 @@ class fpdb_db: MYSQL_INNODB = 2 PGSQL = 3 SQLITE = 4 + sqlite_db_dir = ".." + os.sep + "database" + def __init__(self): """Simple constructor, doesnt really do anything""" self.db = None @@ -120,7 +122,12 @@ class fpdb_db: sqlite3 = pool.manage(sqlite3, pool_size=1) else: logging.warning("SQLite won't work well without 'sqlalchemy' installed.") - self.db = sqlite3.connect(database,detect_types=sqlite3.PARSE_DECLTYPES) + + if not os.path.isdir(self.sqlite_db_dir): + print "Creating directory: '%s'" % (self.sqlite_db_dir) + os.mkdir(self.sqlite_db_dir) + self.db = sqlite3.connect( self.sqlite_db_dir + os.sep + 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") else: