python - How to do a general "search bar" search across multiple SQLAlchemy models -


i have search bar app. user searched 'john smith united kingdom oxford university' return user accounts table name 'john smith', location 'united kingdom' , education 'oxford university'.

here general overview search 'john smith united kingdom oxford university':

  • show accounts database name 'john smith', location 'united kingdom' , education 'oxford university'.
  • show accounts name 'john smith' , education 'oxford university'
  • show accounts name 'john smith' , location 'united kingdom'
  • show accounts name 'john smith'

i cannot find resources flask-sqlalchemy specify how this. i'm aware have use .like() though don't know how add sqlalchemy query in flask. sqlalchemy .where(column.like()) though cannot in flask-sqlalchemy.

how go doing this?

you use like() use in sqlalchemy:

user.query.filter(user.name.like("%john smith%")).all() 

or can use contains():

user.query.filter(user.name.contains('john smith')).all() 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -