This commit is contained in:
Andreas Preikschat 2010-12-05 17:07:16 +01:00
parent b8e6da0417
commit e3cb6a6508
1 changed files with 11 additions and 13 deletions

View File

@ -63,27 +63,25 @@ class OpenLP1Bible(BibleDB):
cursor = connection.cursor() cursor = connection.cursor()
except: except:
return False return False
# Import books. # Create all books.
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
books = cursor.fetchall() books = cursor.fetchall()
for book in books: for book in books:
book_id = int(book[0])
testament_id = int(book[1]) testament_id = int(book[1])
name = unicode(book[2], u'cp1252') name = unicode(book[2], u'cp1252')
abbreviation = unicode(book[3], u'cp1252') abbreviation = unicode(book[3], u'cp1252')
self.wizard.incrementProgressBar(unicode('%s %s' % (translate(
'BiblesPlugin.olp1', 'Importing'), name)))
self.create_book(name, abbreviation, testament_id) self.create_book(name, abbreviation, testament_id)
self.session.commit() # Import the verses for this book.
# Import chapters/verses. cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
for book in books: 'verse WHERE book_id=%s' % book_id)
print u'Importiere %s' % book
cursor.execute(u'SELECT id, book_id, chapter, verse, text || \'\' '
'AS text FROM verse WHERE book_id=%s' % book)
verses = cursor.fetchall() verses = cursor.fetchall()
for verse in verses: for verse in verses:
book_id = int(verse[1]) chapter = int(verse[0])
chapter = int(verse[2]) verse_number = int(verse[1])
verse_number = int(verse[3]) text = unicode(verse[2], u'cp1252')
text = unicode(verse[4], u'cp1252')
self.create_verse(book_id, chapter, verse_number, text) self.create_verse(book_id, chapter, verse_number, text)
self.session.commit() self.session.commit()
return True return True