sqlalchemy regexp_match 忽略大小写

sqlalchemy regexp_match ignore capitalization

我正在尝试匹配这个陈述

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

profile_name栏中,保存为Some_Name。我如何让它匹配忽略大写?

找到答案

from sqlalchemy import func

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