openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #12630
[Merge] lp:~googol/openlp/bug-872975 into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/bug-872975 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #872975 in OpenLP: "Importing from v1 fails with error about missing "settings" table"
https://bugs.launchpad.net/openlp/+bug/872975
For more details, see:
https://code.launchpad.net/~googol/openlp/bug-872975/+merge/80806
- fixed bug #872975 (Importing from v1 fails with error about missing 'settings' table)
--
https://code.launchpad.net/~googol/openlp/bug-872975/+merge/80806
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/bug-872975 into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py 2011-09-12 16:35:32 +0000
+++ openlp/plugins/songs/lib/olp1import.py 2011-10-31 14:22:23 +0000
@@ -78,30 +78,35 @@
connection = sqlite.connect(self.importSource, mode=0444,
encoding=(encoding, 'replace'))
cursor = connection.cursor()
- # Determine if we're using a new or an old DB.
+ # Determine if the db supports linking audio to songs.
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'')
- new_db = len(cursor.fetchall()) > 0
+ db_has_tracks = len(cursor.fetchall()) > 0
+ # Determine if the db contains theme information.
+ cursor.execute(u'SELECT name FROM sqlite_master '
+ u'WHERE type = \'table\' AND name = \'settings\'')
+ db_has_themes = len(cursor.fetchall()) > 0
# "cache" our list of authors.
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT authorid, authorname FROM authors')
authors = cursor.fetchall()
- if new_db:
+ if db_has_tracks:
# "cache" our list of tracks.
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall()
- # "cache" our list of themes.
- cursor.execute(u'-- types int, unicode')
- cursor.execute(u'SELECT settingsid, settingsname FROM settings')
- themes = {}
- for theme_id, theme_name in cursor.fetchall():
- if theme_name in self.availableThemes:
- themes[theme_id] = theme_name
+ if db_has_themes:
+ # "cache" our list of themes.
+ themes = {}
+ cursor.execute(u'-- types int, unicode')
+ cursor.execute(u'SELECT settingsid, settingsname FROM settings')
+ for theme_id, theme_name in cursor.fetchall():
+ if theme_name in self.availableThemes:
+ themes[theme_id] = theme_name
# Import the songs.
- cursor.execute(u'-- types int, unicode, unicode, unicode, int')
- cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, '
- u'copyrightinfo, settingsid FROM songs')
+ cursor.execute(u'-- types int, unicode, unicode, unicode')
+ cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
+ u'lyrics, copyrightinfo FROM songs')
songs = cursor.fetchall()
self.importWizard.progressBar.setMaximum(len(songs))
for song in songs:
@@ -112,8 +117,13 @@
self.title = song[1]
lyrics = song[2].replace(u'\r\n', u'\n')
self.addCopyright(song[3])
- if themes.has_key(song[4]):
- self.themeName = themes[song[4]]
+ if db_has_themes:
+ cursor.execute(u'-- types int')
+ cursor.execute(
+ u'SELECT settingsid FROM songs WHERE songid = %s' % song_id)
+ theme_id = cursor.fetchone()[0]
+ if themes.has_key(theme_id):
+ self.themeName = themes[theme_id]
verses = lyrics.split(u'\n\n')
for verse in verses:
if verse.strip():
@@ -131,7 +141,7 @@
break
if self.stopImportFlag:
break
- if new_db:
+ if db_has_tracks:
cursor.execute(u'-- types int, int')
cursor.execute(u'SELECT trackid, listindex '
u'FROM songtracks '
Follow ups