look for sqlite db in 'database' dir, create dir first if required
This commit is contained in:
parent
daeefd7d8a
commit
c519756a49
|
@ -39,6 +39,8 @@ class fpdb_db:
|
||||||
MYSQL_INNODB = 2
|
MYSQL_INNODB = 2
|
||||||
PGSQL = 3
|
PGSQL = 3
|
||||||
SQLITE = 4
|
SQLITE = 4
|
||||||
|
sqlite_db_dir = ".." + os.sep + "database"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Simple constructor, doesnt really do anything"""
|
"""Simple constructor, doesnt really do anything"""
|
||||||
self.db = None
|
self.db = None
|
||||||
|
@ -120,7 +122,12 @@ class fpdb_db:
|
||||||
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.")
|
||||||
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_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")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user