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
Post a Comment