view = Table('test_view', metadata)
已创建名称为test_view的视图
statement = text("select je.*, j.id as job_details_id, "
"j.process_definition_id, "
"j.mode_of_execution, "
"j.execution_environment, j.is_active, j.is_restored from "
"engineservice.job j left join engineservice.job_execution
je on j.id=je.job_id and je.status not in
('terminated','completed') where j.is_active = TRUE")
上面是用于创建视图的sql语句
create_view = CreateView(view, statement)
postgres_conn.edc_db_engine.execute(create_view)
这里创建了我的视图,但是现在我想在带有会话的该视图上生成查询并实现sqlalchemy弹性搜索。这可能吗?下面我提到的是我的虚拟代码,它不起作用。
user_request_data = json.dumps({'page_size': 5, 'end_date': '', 'filter': [{
'value': 'fin', 'column': 'mode_of_execution'}], 'client_id': '1',
'sort': {'type': '', 'column': ''}, 'start_date': None, 'page': 1})
with postgres_conn.db_session() as session:
job_obj_list = sqlalchemy_elastic_query.elastic_query(
view, user_request_data, session).all()
我想要这样的东西。基本上,我们试图从视图中获取数据
感谢您的帮助