python - Make SQLAlchemy query by list case insensitive -


i'm trying query postgresql database using lists of strings. want return rows column entry matches string , i'd case insensitive finds more things.

fruits = ['apple', 'orange', 'pear', 'grape', 'watermelon', 'asian pear'] 

in case, 'asian pear' can capitalized in database.

obs = session.query(datamodel).filter(datamodel.fruitname._in(fruits)).all() 

i know func.lower() , use individual queries i'm not sure put when using.

i'd use func.lower in single item query:

obs =session.query(datamodel).filter(func.lower(datamodel.fruitname)==func.lower(fruits[5]))).first() 

stupid me...

in writing question, figured out... answer...

session.query(datamodel).filter(func.lower(datamodel.fruitname).in_(fruits)).all() 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -