asyncpg Pool.execute 与 Connection.execute
发布时间:2022-06-06 17:57:04 234
相关标签: # node.js
从池中获取连接然后调用execute连接而不是execute直接调用池对象的用例是什么?
在Pool类的文档中,显示了此示例:
con = await pool.acquire()
try:
await con.execute(...)
finally:
await pool.release(con)
从池中获取连接并用于执行语句。这样做的好处是什么execute
方法直接在Pool
对象,例如以下对象?
async with asyncpg.create_pool(user=pg_user,
password=pg_pass,
host=pg_host,
port=pg_port,
database=pg_db,
command_timeout=60) as pool:
pool.execute(f'TRUNCATE TABLE {table};')
的文档Pool.execute
甚至说明以下内容:
执行一个或多个SQL命令。
Pool 使用其连接之一执行此操作。除此之外,它的行为与 Connection.execute() 相同。
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报