如何使用密码通过异步连接?在Python 3.10中,我看到的所有示例都是无密码连接



我需要使用python中的asyncpg连接到postgresql的示例,而不仅仅是使用用户名,就像网站上的文档中一样https://magicstack.github.io/asyncpg/current/usage.html,但也有密码。

以下是一些示例:https://www.programcreek.com/python/example/102920/asyncpg.connect

tl;dr

return await asyncpg.connect(
user=DBUSER,
password=DBPASSWORD,
database=DBNAME,
host=DBHOST,
port=DBPORT,
)

参数是可选的,具有默认值,如默认主机为localhost,默认端口为5432等。

最新更新