Attempt to fix bug #1154467 by retrying the commit if it fails

This commit is contained in:
Raoul Snyman 2013-12-22 00:45:33 +02:00
parent 6d86abaa37
commit 3a2686be24

View File

@ -35,6 +35,7 @@ import sqlite3
from PyQt4 import QtCore from PyQt4 import QtCore
from sqlalchemy import Column, ForeignKey, or_, Table, types, func from sqlalchemy import Column, ForeignKey, or_, Table, types, func
from sqlalchemy.exc import OperationalError
from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm import class_mapper, mapper, relation
from sqlalchemy.orm.exc import UnmappedClassError from sqlalchemy.orm.exc import UnmappedClassError
@ -48,6 +49,7 @@ log = logging.getLogger(__name__)
RESERVED_CHARACTERS = u'\\.^$*+?{}[]()' RESERVED_CHARACTERS = u'\\.^$*+?{}[]()'
class BibleMeta(BaseModel): class BibleMeta(BaseModel):
""" """
Bible Meta Data Bible Meta Data
@ -257,6 +259,10 @@ class BibleDB(QtCore.QObject, Manager):
text=verse_text text=verse_text
) )
self.session.add(verse) self.session.add(verse)
try:
self.session.commit()
except OperationalError:
# Try again. If it fails again, let the exception happen
self.session.commit() self.session.commit()
def create_verse(self, book_id, chapter, verse, text): def create_verse(self, book_id, chapter, verse, text):