From 63139e8c3b5491bdbf7f13650dccacdd69dacb4b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 6 Sep 2010 22:41:11 +0200 Subject: [PATCH] Just check for the tracks table before importing from it. --- openlp/plugins/songs/lib/olp1import.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index ab3e0d720..968eac25c 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -97,15 +97,19 @@ class OpenLP1SongImport(SongImport): if self.stop_import_flag: success = False break - cursor.execute(u'SELECT fulltrackname FROM tracks t ' - u'JOIN songtracks st ON t.trackid = st.trackid ' - u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) - tracks = cursor.fetchall() - for track in tracks: - if self.stop_import_flag: - success = False - break - self.add_media_file(unicode(track[0], u'cp1252')) + cursor.execute(u'SELECT name FROM sqlite_master ' + u'WHERE type = \'table\' NAME name = \'tracks\'') + table_list = cursor.fetchall() + if len(table_list) > 0: + cursor.execute(u'SELECT fulltrackname FROM tracks t ' + u'JOIN songtracks st ON t.trackid = st.trackid ' + u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) + tracks = cursor.fetchall() + for track in tracks: + if self.stop_import_flag: + success = False + break + self.add_media_file(unicode(track[0], u'cp1252')) if self.stop_import_flag: success = False break