Add support for PGOPTIONS environment variable
还没有人认领这个 Issue。
评估
调研方向
从读取现有 PG 环境变量的 asyncpg/connect_utils.py 开始,并将所需行为与 PostgreSQL 的 libpq 环境变量文档进行对比。在设置 PGOPTIONS 的情况下运行提供的复现程序 test_asyncpg_timeout.py;当 PGOPTIONS 的值被解释为服务器设置,并且 statement_timeout 示例的行为与 psql 一致时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
asyncpg supports an explicit server_options=... dict connection method parameter, but does not seem to populate its value from the PGOPTIONS environment variable. This is a feature request for it to do so.
Specifically, asyncpg/connect_utils.py reads user, host, port, database, password, and SSL information with calls like os.getenv('PGUSER'), os.environ.get('PGHOST'), etc. There is no corresponding call for reading PGOPTIONS.
I would like to set the environment variable PGOPTIONS='-c default_transaction_read_only=on -c statement_timeout=120s' and have asyncpg interpret its values as server_settings the way libpq does. For instance, the below works for psql:
PGOPTIONS='-c statement_timeout=1s' psql -c "SELECT pg_sleep(2)"
ERROR: canceling statement due to statement timeout
but a simple asyncpg script running the same ignores the statement_timeout since it never reads the value of PGOPTIONS.
$ PGOPTIONS='-c statement_timeout=1s' ./test_asyncpg_timeout.py
SELECT 1
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 469
- 平均合并
- 4 天 1 小时
- 30 天内合并 PR
- 14
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MagicStack/asyncpg 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 72/100
MagicStack/asyncpg#1342 ·
-
难度 3/5 1-2 天 新手友好度 56/100
MagicStack/asyncpg#1340 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 28/100
MagicStack/asyncpg#1337 ·
-
难度 4/5 3-5 天 新手友好度 42/100
MagicStack/asyncpg#1330 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 38/100
MagicStack/asyncpg#1322 ·
查看 MagicStack/asyncpg 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
gradio-app/gradio#13895 ·
维护者通常 1 天内回复
-
build-error
难度 2/5 1-3 小时 新手友好度 76/100
spack/spack-packages#6713 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
ActivityWatch/activitywatch#1464 · 1 个 reaction ·
维护者通常 1 天内回复
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search results未关闭
难度 2/5 1-3 小时 新手友好度 78/100
bytedance/trae-agent#483 ·
维护者通常 1 天内回复