Fix #2757 (Sqlalchemy >1.30 <1.4.24 wasn't supported anymore)

This commit is contained in:
Ozzie Isaacs 2023-04-22 09:25:54 +02:00
parent f2369609e8
commit fe4dc1bb8f

View File

@ -993,7 +993,12 @@ class CalibreDB:
title = title[len(prep):] + ', ' + prep
return title.strip()
conn = conn or self.session.connection().connection.driver_connection
try:
# sqlalchemy <1.4.24
conn = conn or self.session.connection().connection.driver_connection
except AttributeError:
# sqlalchemy >1.4.24 and sqlalchemy 2.0
conn = conn or self.session.connection().connection.connection
try:
conn.create_function("title_sort", 1, _title_sort)
except sqliteOperationalError: