我正在尝试在 Pyramid 中动态生成一些 sqlalchemy 查询。
queries=[]
if var1=='1':
queries.append("Table.name.in_(['Dave'])")
if var2=='2':
queries.append("Table.last_name.in_(['Thomas'])")
qq = (','.join(queries))
if len(queries) > 1:
query = DBSession.query(Table).filter(and_('%s')) % qq
else:
query = DBSession.query(Table).filter('%s') % qq
我收到一个错误:"TypeError: unsupported operand type(s) for %: 'Query' and 'str'"
我该怎么做?