From 8f04f587ecfb2d24bbdf8885fd2be9950f685c8b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 16 Jun 2016 22:58:11 +0200 Subject: [PATCH] Fix MediaShout import issue when an expected table is missing. Fixes bug 1590657. Fixes: https://launchpad.net/bugs/1590657 --- openlp/plugins/songs/lib/importers/mediashout.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/mediashout.py b/openlp/plugins/songs/lib/importers/mediashout.py index 323d99acd..54d3e2c6b 100644 --- a/openlp/plugins/songs/lib/importers/mediashout.py +++ b/openlp/plugins/songs/lib/importers/mediashout.py @@ -59,6 +59,7 @@ class MediaShoutImport(SongImport): songs = cursor.fetchall() self.import_wizard.progress_bar.setMaximum(len(songs)) for song in songs: + topics = [] if self.stop_import_flag: break cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = %s ORDER BY Type, Number' @@ -66,9 +67,10 @@ class MediaShoutImport(SongImport): verses = cursor.fetchall() cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = %s ORDER BY POrder' % song.Record) verse_order = cursor.fetchall() - cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId ' - 'WHERE SongThemes.Record = %s' % song.Record) - topics = cursor.fetchall() + if cursor.tables(table='TableName', tableType='TABLE').fetchone(): + cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId ' + 'WHERE SongThemes.Record = %s' % song.Record) + topics = cursor.fetchall() cursor.execute('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId ' 'WHERE SongGroups.Record = %s' % song.Record) topics += cursor.fetchall()