diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 5b03e5fa4..e51271624 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -34,6 +34,7 @@ from PyQt4 import QtCore from sqlalchemy import create_engine, MetaData from sqlalchemy.exceptions import InvalidRequestError from sqlalchemy.orm import scoped_session, sessionmaker +from sqlalchemy.pool import NullPool from openlp.core.utils import AppLocation, delete_file @@ -52,7 +53,7 @@ def init_db(url, auto_flush=True, auto_commit=False): ``auto_commit`` Sets the commit behaviour of the session """ - engine = create_engine(url) + engine = create_engine(url, poolclass=NullPool) metadata = MetaData(bind=engine) session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine)) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 0cf3b8a26..87da5fc52 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -500,12 +500,6 @@ class BibleDB(QtCore.QObject, Manager): return True return False - def close_database(self): - """ - Close database connection. - """ - self.session.close() - def dump_bible(self): """ Utility debugging method to dump the contents of a bible. @@ -1006,13 +1000,6 @@ class OldBibleDB(QtCore.QObject, Manager): self.cursor = conn.cursor() return self.cursor - def close_cursor(self): - """ - Close the cursor - """ - if self.cursor: - self.cursor.close() - def run_sql(self, query, parameters=()): """ Run an SQL query on the database, returning the results. diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 5fb235520..2699462c3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -156,6 +156,7 @@ class BibleManager(object): # Find old database versions if bible.is_old_database(): self.old_bible_databases.append(filename) + bible.session.close() continue log.debug(u'Bible Name: "%s"', name) self.db_cache[name] = bible