0

I want to query data from database use sqlalchemy, and the code is below:

    session.query(Person).filter(Person.name.like("%tom%")).all()

but this is case sensitive, in other words, the params of like is just match "tom" and dose not contain "TOM". How to deal with the query without case sensitive ?

zimmer
  • 1,159
  • 3
  • 13
  • 23
  • Look at - http://stackoverflow.com/questions/16573095/case-insensitive-flask-sqlalchemy-query?answertab=votes#tab-top – a.m. Nov 11 '13 at 07:02

1 Answers1

0

You can use sqlalchemy's built-in ilike.

e.g

select([sometable]).where(sometable.c.column.ilike("%foobar%"))

ILIKE is quasi-standard, it is supported by MySQL and PostgresQL.

Leonardo.Z
  • 9,425
  • 3
  • 35
  • 38