Just use getattr standard python library function to get an attribute by name:
col_name="subject"
db_session.query(Notice).filter(getattr(Notice, col_name).like("%" + query + "%"))
More Related Contents:
- Writing a connection string when password contains special characters
- Does SQLAlchemy have an equivalent of Django’s get_or_create?
- How to write DataFrame to postgres table
- Speeding up pandas.DataFrame.to_sql with fast_executemany of pyODBC
- CS50: LIKE operator, variable substitution with % expansion
- SQLAlchemy: What’s the difference between flush() and commit()?
- Group by & count function in sqlalchemy
- Debugging (displaying) SQL command sent to the db by SQLAlchemy
- SQL Alchemy ORM returning a single column, how to avoid common post processing
- How do I execute inserts and updates in an Alembic upgrade script?
- SQLAlchemy, get object not bound to a Session
- Flask sqlalchemy many-to-many insert data
- How to delete a record by id in Flask-SQLAlchemy
- How to upsert pandas DataFrame to PostgreSQL table?
- How to do an upsert with SqlAlchemy?
- SQLAlchemy printing raw SQL from create()
- SQLAlchemy: how to filter date field?
- method of iterating over sqlalchemy model’s defined columns?
- How to execute “left outer join” in SqlAlchemy
- flask-sqlalchemy or sqlalchemy
- python pandas to_sql with sqlalchemy : how to speed up exporting to MS SQL?
- SQLAlchemy Obtain Primary Key With Autoincrement Before Commit
- How to set connection timeout in SQLAlchemy
- SQLAlchemy – can you add custom methods to the query object?
- Reverse engineer SQLAlchemy declarative class definition from existing MySQL database?
- Which SQLAlchemy column type should be used for binary data?
- SQLAlchemy classes across files
- VALUES clause in SQLAlchemy
- How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?
- flask sqlalchemy query with keyword as variable