Skip to content

Commit

Permalink
Always catch sqlite create_function error
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzieIsaacs committed Apr 24, 2022
1 parent bc96ff9 commit 8421a17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cps/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from urllib.parse import quote
import unidecode

from sqlite3 import OperationalError as sqliteOperationalError
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, ForeignKey, CheckConstraint
from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float
Expand Down Expand Up @@ -942,7 +943,7 @@ def _title_sort(title):
conn = conn or self.session.connection().connection.connection
try:
conn.create_function("title_sort", 1, _title_sort)
except OperationalError:
except sqliteOperationalError:
pass

@classmethod
Expand Down
12 changes: 6 additions & 6 deletions cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from flask_babel import gettext as _
from flask_login import current_user, login_required
from sqlalchemy.exc import OperationalError, IntegrityError
from sqlite3 import OperationalError as sqliteOperationalError
# from sqlite3 import OperationalError as sqliteOperationalError
from . import constants, logger, isoLanguages, gdriveutils, uploader, helper, kobo_sync_status
from . import config, get_locale, ub, db
from . import calibre_db
Expand Down Expand Up @@ -757,11 +757,11 @@ def edit_book(book_id):
edit_error = False

# create the function for sorting...
try:
calibre_db.update_title_sort(config)
except sqliteOperationalError as e:
log.error_or_exception(e)
calibre_db.session.rollback()
#try:
calibre_db.update_title_sort(config)
#except sqliteOperationalError as e:
# log.error_or_exception(e)
# calibre_db.session.rollback()

book = calibre_db.get_filtered_book(book_id, allow_show_archived=True)
# Book not found
Expand Down

0 comments on commit 8421a17

Please sign in to comment.