Commit verses at end

This commit is contained in:
Jonathan Corwin 2010-03-22 08:45:45 +00:00
parent 06342a0fa9
commit 5f2a637b63

View File

@ -135,7 +135,7 @@ class MigrateBibles():
def _v1_9_0_old(self, database): def _v1_9_0_old(self, database):
self.progress(u'Rename Tables ' + database) self.progress(u'Rename Tables ' + database)
conn = sqlite3.connect(self.data_path + os.sep + database) conn = sqlite3.connect(os.path.join(self.data_path, database))
conn.execute(u'alter table book rename to book_temp;') conn.execute(u'alter table book rename to book_temp;')
conn.commit() conn.commit()
conn.execute(u'alter table testament rename to testament_temp;') conn.execute(u'alter table testament rename to testament_temp;')
@ -178,33 +178,24 @@ class MigrateBibles():
self.session.rollback() self.session.rollback()
print u'Error thrown = ', sys.exc_info()[1] print u'Error thrown = ', sys.exc_info()[1]
self.progress(u'Create verse table') self.progress(u'Create verse table')
#---- results = self.session.query(TVerse).order_by(TVerse.id).all()
#results = self.session.query(TVerse).order_by(TVerse.id).all() for verse_temp in results:
#for verse_temp in results: verse = Verse()
# verse = Verse() verse.id = verse_temp.id
# verse.id = verse_temp.id verse.book_id = verse_temp.book_id
# verse.book_id = verse_temp.book_id verse.chapter = verse_temp.chapter
# verse.chapter = verse_temp.chapter verse.verse = verse_temp.verse
# verse.verse = verse_temp.verse verse.text = verse_temp.text
# verse.text = verse_temp.text try:
# try: self.session.add(verse)
# self.session.add(verse) except:
# self.session.commit() self.session.rollback()
# except: print u'Error thrown = ', sys.exc_info()[1]
# self.session.rollback()
# print u'Error thrown = ', sys.exc_info()[1]
#
# The above is too slow, took hours to not finish one bible
# For now, just do it the old fashioned way
#---
try: try:
conn = sqlite3.connect(self.data_path + os.sep + database) self.session.commit()
conn.execute(u'insert into verse select * from verse_temp;')
conn.commit()
except: except:
self.session.rollback() self.session.rollback()
print u'Error thrown = ', sys.exc_info()[1] print u'Error thrown = ', sys.exc_info()[1]
#---
self.progress(u'Create metadata table') self.progress(u'Create metadata table')
results = self.session.query(TBibleMeta).order_by(TBibleMeta.key).all() results = self.session.query(TBibleMeta).order_by(TBibleMeta.key).all()
for biblemeta_temp in results: for biblemeta_temp in results:
@ -220,7 +211,7 @@ class MigrateBibles():
def _v1_9_0_cleanup(self, database): def _v1_9_0_cleanup(self, database):
self.progress(u'Update Internal Data ' + database) self.progress(u'Update Internal Data ' + database)
conn = sqlite3.connect(self.data_path + os.sep + database) conn = sqlite3.connect(os.path.join(self.data_path, database))
conn.commit() conn.commit()
conn.execute(u'drop table book_temp;') conn.execute(u'drop table book_temp;')
conn.commit() conn.commit()