【问题标题】:How to get "returning id" using asyncpg(pgsql)如何使用 asyncpg(pgsql) 获取“返回 id”
【发布时间】:2019-05-23 22:07:15
【问题描述】:

在Python中使用asyncpg执行insert语句,使用returning id语法获取每个insert的ID,但返回的是“INSERT 0 1”

Python 3.5

asyncpg(使用连接池)

【问题讨论】:

  • 我在con.execute()之后没有看到任何con.fetchone()
  • 所以我需要使用 fetchval 吗?

标签: python python-3.x postgresql asyncpg


【解决方案1】:

Connection.fetch()(及其变体)可用于返回任何数据返回语句的结果,包括INSERT ... RETURNING

【讨论】:

    猜你喜欢
    • 2021-05-13
    • 2018-04-18
    • 2021-10-30
    • 2021-09-01
    • 2019-07-01
    • 1970-01-01
    • 2021-10-17
    • 2019-04-09
    • 2020-03-18
    相关资源
    最近更新 更多