我正在asyncpg查看文档,我无法理解为什么使用连接池而不是单个连接.
async with pool.acquire() as connection:
async with connection.transaction():
result = await connection.fetchval('select 2 ^ $1', power)
return web.Response(
text="2 ^ {} is {}".format(power, result))
Run Code Online (Sandbox Code Playgroud)
但也可以通过在必要时创建连接来完成:
connection = await asyncpg.connect(user='postgres')
async with connection.transaction():
result = await connection.fetchval('select 2 ^ $1', power)
return web.Response(
text="2 ^ {} is {}".format(power, result))
Run Code Online (Sandbox Code Playgroud)
根据需要使用池而不是连接有什么好处?
我正在使用 xlwings 开发一个新项目,我想知道是否以及如何可以访问和/或设置工作簿的命名范围名称。
我知道我们可以使用该函数访问命名范围Range(),但是是否可以获取特定工作簿(例如调用者)的名称列表并从 python 创建命名范围?