prevent crasher when connecting to empty mysql (presumably this bug also applied to postgres)
This commit is contained in:
parent
b549feab03
commit
2813bb7fe6
|
@ -244,8 +244,9 @@ class Database:
|
|||
# create index indexname on tablename (col);
|
||||
|
||||
|
||||
def __init__(self, c, sql = None, autoconnect = True):
|
||||
def __init__(self, c, sql = None, autoconnect = True, create_db=False):
|
||||
#log = Configuration.get_logger("logging.conf", "db", log_dir=c.dir_log)
|
||||
print "create DB=",create_db
|
||||
log.debug(_("Creating Database instance, sql = %s") % sql)
|
||||
self.config = c
|
||||
self.__connected = False
|
||||
|
@ -307,7 +308,7 @@ class Database:
|
|||
|
||||
self.saveActions = False if self.import_options['saveActions'] == False else True
|
||||
|
||||
if self.is_connected():
|
||||
if self.is_connected() and not create_db:
|
||||
self.get_sites()
|
||||
self.connection.rollback() # make sure any locks taken so far are released
|
||||
#end def __init__
|
||||
|
|
|
@ -880,7 +880,7 @@ class fpdb:
|
|||
self.sql = SQL.Sql(db_server = self.settings['db-server'])
|
||||
err_msg = None
|
||||
try:
|
||||
self.db = Database.Database(self.config, sql = self.sql)
|
||||
self.db = Database.Database(self.config, sql = self.sql, create_db=create_db)
|
||||
if self.db.get_backend_name() == 'SQLite':
|
||||
# tell sqlite users where the db file is
|
||||
print (_("Connected to SQLite: %s") % self.db.db_path)
|
||||
|
|
Loading…
Reference in New Issue
Block a user