From: Oleg Broytman Date: Sun, 27 Mar 2016 21:12:11 +0000 (+0300) Subject: Add unicode-aware function 'lower()' to SQLite X-Git-Tag: 0.0.4~47 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=bb394bd389c243d3b285f9c434e6b9deb5e8833c;p=m_librarian.git Add unicode-aware function 'lower()' to SQLite --- diff --git a/m_librarian/db.py b/m_librarian/db.py index 99a2843..cd2f644 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -45,6 +45,18 @@ if not db_uri: sqlhub.processConnection = connection = connectionForURI(db_uri) if connection.dbName == 'sqlite': + def lower(s): + return s.lower() + + sqlite = connection.module + + class MLConnection(sqlite.Connection): + def __init__(self, *args, **kwargs): + super(MLConnection, self).__init__(*args, **kwargs) + self.create_function('lower', 1, lower) + + connection._connOptions['factory'] = MLConnection + # Speedup SQLite connection connection.query("PRAGMA synchronous=OFF") connection.query("PRAGMA count_changes=OFF")