我正在尝试使用 SQLAlchemy 在 Python 中实现 PostgreSQL 查询,但无济于事。我的查询如下:
with given ("id", "instance") as (
values (1, 1), (108, 23), (203, 5)
)
select given."id" from given
left join panel on panel."id" = given."id" and panel.instance_id = given."instance"
where panel."id" is null
Run Code Online (Sandbox Code Playgroud)
我尝试了许多不同的方法,但主要问题是我无法使用 CTE 语句创建“给定”表,无法预定义列名并提供所需的值。
这是关于SQLAlchemy 中 VALUES 子句的有用线程,但我仍然没有设法解决这个问题。
对这个问题的任何见解都非常受欢迎!