I am using sqlalchemy core (query builder) to do an insert using a table definition. For example:
table.insert().values(a,b,c)
and I can make it return specific columns:
table.insert().values(a,b,c).returning(table.c.id, table.c.name)
but I am using postgres which has a RETURNING *
syntax, which returns all the columns in the row. Is there a way to do that with sqlalchemy core?
query = table.insert().values(a,b,c).returning(literal_column('*'))
And you can access it like
for col in execute(query, stmt):
print(col)
要获取所有表列,还可以执行以下查询:
table.insert().values(a,b,c).returning(table)
或者,您可以扩展表列:
table.insert().returning(*table.c).values(a,b,c)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.