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 + "%"))
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 + "%"))