diff --git a/.eric4project/openlp.org 2.0.e4q b/.eric4project/openlp.org 2.0.e4q
index 63d35f777..c90790196 100644
--- a/.eric4project/openlp.org 2.0.e4q
+++ b/.eric4project/openlp.org 2.0.e4q
@@ -4,4 +4,4 @@
-
\ No newline at end of file
+
diff --git a/.eric4project/openlp.org 2.0.e4t b/.eric4project/openlp.org 2.0.e4t
index 0512aad27..797daa910 100644
--- a/.eric4project/openlp.org 2.0.e4t
+++ b/.eric4project/openlp.org 2.0.e4t
@@ -111,4 +111,4 @@
534
-
\ No newline at end of file
+
diff --git a/openlp.org 2.0.e4p b/openlp.org 2.0.e4p
index 3e2e55bb1..f0695f12b 100644
--- a/openlp.org 2.0.e4p
+++ b/openlp.org 2.0.e4p
@@ -148,7 +148,7 @@
openlp.pyw
- Subversion
+ PySvn
@@ -220,7 +220,7 @@
-
+
diff --git a/openlp/plugins/songs/lib/meta.py b/openlp/plugins/songs/lib/meta.py
new file mode 100644
index 000000000..b9ba66b98
--- /dev/null
+++ b/openlp/plugins/songs/lib/meta.py
@@ -0,0 +1,33 @@
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+"""
+OpenLP - Open Source Lyrics Projection
+Copyright (c) 2008 Raoul Snyman
+Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+from sqlalchemy import MetaData
+from sqlalchemy.orm import scoped_session, sessionmaker
+
+__all__ = ['session', 'metadata', 'engine']
+
+# SQLAlchemy database engine. Updated by model.init_model()
+engine = None
+
+# SQLAlchemy session manager. Updated by model.init_model()
+session = None
+
+# Global metadata. If you have multiple databases with overlapping table
+# names, you'll need a metadata for each database
+metadata = MetaData()
\ No newline at end of file
diff --git a/openlp/plugins/songs/lib/models.py b/openlp/plugins/songs/lib/models.py
index d6294e23c..81ba42e30 100644
--- a/openlp/plugins/songs/lib/models.py
+++ b/openlp/plugins/songs/lib/models.py
@@ -20,22 +20,22 @@ Place, Suite 330, Boston, MA 02111-1307 USA
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
+from openlp.plugins.songs.lib.meta import session, metadata, engine
from openlp.plugins.songs.lib.tables import *
from openlp.plugins.songs.lib.classes import *
-session = None
-
def init_models(url):
+ engine = create_engine(url)
session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
- bind=create_engine(url)))
+ bind=engine))
+ metadata.bind = engine
-
-#mapper(Author, authors_table)
-#mapper(Book, song_books_table)
-#mapper(Song, songs_table,
-# properties={'authors': relation(Author, backref='songs',
-# secondary=authors_songs_table),
-# 'book': relation(Book, backref='songs'),
-# 'topics': relation(Topic, backref='songs',
-# secondary=songs_topics_table)})
-#mapper(Topic, topics_table)
+mapper(Author, authors_table)
+mapper(Book, song_books_table)
+mapper(Song, songs_table,
+ properties={'authors': relation(Author, backref='songs',
+ secondary=authors_songs_table),
+ 'book': relation(Book, backref='songs'),
+ 'topics': relation(Topic, backref='songs',
+ secondary=songs_topics_table)})
+mapper(Topic, topics_table)
diff --git a/openlp/plugins/songs/lib/tables.py b/openlp/plugins/songs/lib/tables.py
index 42889d8be..1bdd51a4e 100644
--- a/openlp/plugins/songs/lib/tables.py
+++ b/openlp/plugins/songs/lib/tables.py
@@ -14,12 +14,12 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
+Place, Suite 330, Boston, MA 02111-1307 USA
"""
-from sqlalchemy import Column, Table, MetaData, ForeignKey, types
+from sqlalchemy import Column, Table, ForeignKey, types
-metadata = MetaData()
+from openlp.plugins.songs.lib.meta import metadata
# Definition of the "authors" table
authors_table = Table('authors', metadata,