一个用于解析和操作PostgreSQL libpq样式的连接字符串和uri的工具
pgconnstr的Python项目详细描述
pgconnstr公司
一个Python模块,用于解析和操作PostgreSQL libpq样式的连接字符串和uri。在
许可证
LGPLv3。有关详细信息,请参阅文件LICENSE
。在
类连接字符串
在pgconnstr.ConnectionString表示libpq连接字符串。在
>>>frompgconnstrimportConnectionString>>>c=ConnectionString(host='1.2.3.4',dbname='mydb',port=5432,user='anon',...password="sec'ret",application_name='myapp')...>>>print(str(c))application_name=myappdbname=mydbhost=1.2.3.4password=sec\'ret port=5432 user=anon>>>print(str(ConnectionString(str(c),dbname='otherdb')))application_name=myappdbname=otherdbhost=1.2.3.4password=sec\'ret port=5432 user=anon
组件可以作为属性访问。在
^{pr2}$如果没有明确设置,标准组件将默认为无。看到了吗 https://www.postgresql.org/docs/12/libpq-connect.html#LIBPQ-PARAMKEYWORDS 标准关键字列表。在
>>>c.connect_timeoutisNoneTrue
标准URI格式也可以访问:
>>>print(c.uri)postgresql://anon:sec%27ret@1.2.3.4:5432/mydb?application_name=myapp>>>print(ConnectionString(c,host='2001:db8::1234').uri)postgresql://anon:sec%27ret@[2001:db8::1234]:5432/mydb?application_name=myapp
- 项目
标签: