具有一个从SQLAlchemy返回Query对象的函数,我该如何执行它?我试图在各个函数中创建查询,然后根据输入内容在main方法中执行
例如
def get_plan_query():
return session.query(Plan.name).filter(Plan.id==2)
def get_plan_query_2():
return session.query(Plan.name).filter(Plan.author == 'clark')
def download_data():
pd.read_sql(session.query(union(get_plan_query(), get_plan_query_2()).statement, session.bind) # <- This does not work