Skip to content
Advertisement

PostgreSQL ILIKE query with SQLAlchemy

I’d like to run a query that selects all posts, case insensitive, that have titles that match '%' + [some_phrase] + '%'. That is, select all rows that have titles that contain some phrase, case insensitive. From the research I’ve done, it looks like I need to use Postgres’s ILIKE query for it to match case insensitive. How can I execute a query like this with SQLAlchemy?

JavaScript

Advertisement

Answer

I think it should work

JavaScript

http://docs.sqlalchemy.org/en/latest/orm/internals.html?highlight=ilike#sqlalchemy.orm.attributes.QueryableAttribute.ilike

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