- added a global const to config to point to "database" directory
- adjusted fpdb_db.py to make use use of this const
This commit is contained in:
parent
a18091161a
commit
62c915928d
|
@ -50,6 +50,10 @@ log.debug("config logger initialised")
|
||||||
APPLICATION_NAME_SHORT = 'fpdb'
|
APPLICATION_NAME_SHORT = 'fpdb'
|
||||||
APPLICATION_VERSION = 'xx.xx.xx'
|
APPLICATION_VERSION = 'xx.xx.xx'
|
||||||
|
|
||||||
|
DIR_SELF = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
#TODO: imo no good idea to place 'database' in parent dir
|
||||||
|
DIR_DATABASES = os.path.join(os.path.dirname(DIR_SELF), 'database')
|
||||||
|
|
||||||
DATABASE_TYPE_POSTGRESQL = 'postgresql'
|
DATABASE_TYPE_POSTGRESQL = 'postgresql'
|
||||||
DATABASE_TYPE_SQLITE = 'sqlite'
|
DATABASE_TYPE_SQLITE = 'sqlite'
|
||||||
DATABASE_TYPE_MYSQL = 'mysql'
|
DATABASE_TYPE_MYSQL = 'mysql'
|
||||||
|
|
|
@ -33,12 +33,12 @@ except ImportError:
|
||||||
|
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
|
import Configuration
|
||||||
|
|
||||||
class fpdb_db:
|
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"""
|
||||||
|
@ -123,10 +123,10 @@ class fpdb_db:
|
||||||
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.sqlite_db_dir):
|
if not os.path.isdir(Configuration.DIR_DATABASES):
|
||||||
print "Creating directory: '%s'" % (self.sqlite_db_dir)
|
print "Creating directory: '%s'" % (Configuration.DIR_DATABASES)
|
||||||
os.mkdir(self.sqlite_db_dir)
|
os.mkdir(Configuration.DIR_DATABASES)
|
||||||
self.db = sqlite3.connect( self.sqlite_db_dir + os.sep + database
|
self.db = sqlite3.connect( os.path.join(Configuration.DIR_DATABASES, database)
|
||||||
, detect_types=sqlite3.PARSE_DECLTYPES )
|
, 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