forked from openlp/openlp
fix Traceback like Jonathan recommand
This commit is contained in:
parent
af38bf7cc8
commit
d3148f90f8
@ -34,6 +34,7 @@ from PyQt4 import QtCore
|
|||||||
from sqlalchemy import create_engine, MetaData
|
from sqlalchemy import create_engine, MetaData
|
||||||
from sqlalchemy.exceptions import InvalidRequestError
|
from sqlalchemy.exceptions import InvalidRequestError
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||||
|
from sqlalchemy.pool import NullPool
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation, delete_file
|
from openlp.core.utils import AppLocation, delete_file
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ def init_db(url, auto_flush=True, auto_commit=False):
|
|||||||
``auto_commit``
|
``auto_commit``
|
||||||
Sets the commit behaviour of the session
|
Sets the commit behaviour of the session
|
||||||
"""
|
"""
|
||||||
engine = create_engine(url)
|
engine = create_engine(url, poolclass=NullPool)
|
||||||
metadata = MetaData(bind=engine)
|
metadata = MetaData(bind=engine)
|
||||||
session = scoped_session(sessionmaker(autoflush=auto_flush,
|
session = scoped_session(sessionmaker(autoflush=auto_flush,
|
||||||
autocommit=auto_commit, bind=engine))
|
autocommit=auto_commit, bind=engine))
|
||||||
|
@ -500,12 +500,6 @@ class BibleDB(QtCore.QObject, Manager):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def close_database(self):
|
|
||||||
"""
|
|
||||||
Close database connection.
|
|
||||||
"""
|
|
||||||
self.session.close()
|
|
||||||
|
|
||||||
def dump_bible(self):
|
def dump_bible(self):
|
||||||
"""
|
"""
|
||||||
Utility debugging method to dump the contents of a bible.
|
Utility debugging method to dump the contents of a bible.
|
||||||
@ -1006,13 +1000,6 @@ class OldBibleDB(QtCore.QObject, Manager):
|
|||||||
self.cursor = conn.cursor()
|
self.cursor = conn.cursor()
|
||||||
return self.cursor
|
return self.cursor
|
||||||
|
|
||||||
def close_cursor(self):
|
|
||||||
"""
|
|
||||||
Close the cursor
|
|
||||||
"""
|
|
||||||
if self.cursor:
|
|
||||||
self.cursor.close()
|
|
||||||
|
|
||||||
def run_sql(self, query, parameters=()):
|
def run_sql(self, query, parameters=()):
|
||||||
"""
|
"""
|
||||||
Run an SQL query on the database, returning the results.
|
Run an SQL query on the database, returning the results.
|
||||||
|
@ -156,6 +156,7 @@ class BibleManager(object):
|
|||||||
# Find old database versions
|
# Find old database versions
|
||||||
if bible.is_old_database():
|
if bible.is_old_database():
|
||||||
self.old_bible_databases.append(filename)
|
self.old_bible_databases.append(filename)
|
||||||
|
bible.session.close()
|
||||||
continue
|
continue
|
||||||
log.debug(u'Bible Name: "%s"', name)
|
log.debug(u'Bible Name: "%s"', name)
|
||||||
self.db_cache[name] = bible
|
self.db_cache[name] = bible
|
||||||
|
Loading…
Reference in New Issue
Block a user