prevent crasher when connecting to empty mysql (presumably this bug also applied to postgres)

This commit is contained in:
Steffen Schaumburg 2010-12-25 20:38:18 +01:00
parent b549feab03
commit 2813bb7fe6
2 changed files with 4 additions and 3 deletions

View File

@ -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__

View File

@ -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)