ProfP30
ProfP30

Reputation: 358

SQlite user defined function in python

Because SQLite has problems with upper() and lower() with german umlauts, I need to create a user function in python.

Problem: Data in SQlite: address -> Elsa-Brändström-Str. nn address.upper() -> ELSA-BRäNDSTRöM-STR. nn <-- still small umlauts "ö" and "ä"

Same problem for capital letters if I call lower(). The umlauts just won't change their casing with lower() and upper().

So I can't search for upper WHERE-Clause from my GUI... :-/

I've tried to follow this steps as a first test: https://dzone.com/articles/adding-function-sqlite-python

But always get "sqlite3.OperationalError: user-defined function raised exception"

How could such a "LIKE-"like py-function look like?

SQLite3 python 3.7.1

Upvotes: 1

Views: 925

Answers (1)

vi_me
vi_me

Reputation: 408

use u'ÅÄÖABC' to show it's a unicode string

>>> u'ÅÄÖABC'.lower()
'åäöabc'

and

>>> u'åäöabc'.upper()
'ÅÄÖABC'

Upvotes: 1

Related Questions