diff --git a/openlp/migration/migratebibles.py b/openlp/migration/migratebibles.py index 0bdb44f47..37b2fd305 100644 --- a/openlp/migration/migratebibles.py +++ b/openlp/migration/migratebibles.py @@ -86,13 +86,6 @@ mapper(TTestament, temp_testament_table) mapper(TBook, temp_book_table) mapper(TVerse, temp_verse_table) -def init_models(url): - engine = create_engine(url) - metadata.bind = engine - session = scoped_session(sessionmaker(autoflush=False, - autocommit=False, bind=engine)) - return session - class MigrateBibles(object): def __init__(self, display): self.display = display diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 82fb9f767..38c4dfb1f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -87,8 +87,8 @@ class BibleDB(QtCore.QObject): unicode(settings.value(u'db hostname').toString()), unicode(settings.value(u'db database').toString())) settings.endGroup() - self.metadata, self.session = init_models(db_url) - self.metadata.create_all(checkfirst=True) + self.session = init_models(db_url) + metadata.create_all(checkfirst=True) if u'file' in kwargs: self.get_name() diff --git a/openlp/plugins/bibles/lib/models.py b/openlp/plugins/bibles/lib/models.py index 4631b1e32..2af01f55e 100644 --- a/openlp/plugins/bibles/lib/models.py +++ b/openlp/plugins/bibles/lib/models.py @@ -73,10 +73,9 @@ class Verse(BaseModel): def init_models(db_url): engine = create_engine(db_url) metadata.bind = engine - session = scoped_session(sessionmaker(autoflush=True, - autocommit=False, - bind=engine)) - return metadata, session + session = scoped_session(sessionmaker(autoflush=True, autocommit=False, + bind=engine)) + return session metadata = MetaData() meta_table = Table(u'metadata', metadata,