Skip to content
Advertisement

SQLAlchemy substring is in string

I am trying to query a database for records that have a string field inside an input search string.

Something like this:

Of course that does not work since it is not a valid SQLAlchemy statement. This seems a simple problem but I really can’t find the right column operator.

I tried the in_ operator:

But that of course is not working. What I need is a is_substring operator.

Advertisement

Answer

In SQL it would be

SQLAlchemy contains(other) produces the clause LIKE '%<other>%'

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement