Answer the question
In order to leave comments, you need to log in
How to fix error when using OR and custom function?
Function
def lower_string(_str):
return _str.lower()
con.create_function("LOWER", 1, lower_string)
SELECT * FROM incoming WHERE lower("index") LIKE lower("%иванов%")
SELECT * FROM incoming WHERE lower("index") LIKE lower("%иванов%") OR
lower("num_incoming") LIKE lower("%иванов%")
sqlite3.OperationalError: user-defined function raised exception
Answer the question
In order to leave comments, you need to log in
Everything turned out to be quite obvious: Since not all fields in the table were of string type, the lower() function could not process them. To fix the error, I simply added a conversion to the string:
def lower_string(_str):
return str(_str).lower()
Why write your own function when there is a built-in one?
https://www.w3resource.com/sqlite/core-functions-l...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question