S
S
SMOrc2021-01-29 17:52:39
SQLite
SMOrc, 2021-01-29 17:52:39

How to make search case insensitive in Flask Sqlite?

This code searches case sensitive

ru_riddles = riddles.query.filter(riddles.ruText.contains(q)).all()

This code too, although it should search without case
ru_riddles = riddles.query.filter(riddles.ruText.like(q)).all()

If you replace just q with "%" + q + "%", nothing changes.
I tried to execute a query in DB Browser (SQLite) And even there it did not work . Is it possible to execute such a query in SQLite at all? Personally, I don't think so
SELECT * FROM riddles WHERE ruText LIKE "%текст%"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Yakushenko, 2021-01-29
@kshnkvn

I understand you have sqlalchemy, try ilike , but I don't know if it works correctly with sqlite:

ru_riddles = riddles.query.filter(riddles.ruText.ilike(q)).all()

D
Dr. Bacon, 2021-01-29
@bacon

Known issue with SQLite

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question