sqlalchemy regexp_match ignore capitalization

Viewed 13

I am trying to match this statement

stmt = session.query(models.Production).filter(models.Production.profile_name.regexp_match('some_name'))
results = session.execute(stmt).all()
print(results)

In profile_name column, it's saved as Some_Name. How do I get it to match ignoring capitalization?

1 Answers

Found an answer

from sqlalchemy import func

stmt = session.query(models.Production).filter(func.lower(models.Production.profile_name).regexp_match(func.lower('some_name')))
Related