异步Postgres客户端和混入模块,用于Tornado应用程序
项目描述
一套用于使用aiopg在Tornado / sprockets.http应用程序中通过asyncio与PostgreSQL交互的混入模块和类。
安装
sprockets-postgres 可在Python包索引中找到,并通过pip安装
pip install sprockets-postgres
文档
文档可在 sprockets-postgres.readthedocs.io 查找。
配置
通过环境变量或 tornado.web.Application.settings 字典进行sprockets-postgres的配置。 sprockets_postgres.ApplicationMixin 将使用应用于设置字典的配置,如果字典中没有设置值,则回退到环境变量。设置字典中的键为小写,如果作为环境变量提供,则为大写。
下表详细说明了可用的配置选项
变量 |
定义 |
类型 |
默认 |
---|---|---|---|
postgres_url |
要连接到的PostgreSQL URL |
str |
|
postgres_max_pool_size |
每个后端的最大连接数 |
int |
10 |
postgres_min_pool_size |
最小或起始池大小。 |
int |
1 |
postgres_connection_timeout |
尝试创建新连接时允许的最大秒数。 |
int |
10 |
postgres_connection_ttl |
池连接的生命周期,以秒为单位。 |
int |
300 |
postgres_query_timeout |
查询的最大执行时间,以秒为单位。 |
int |
60 |
postgres_hstore |
在客户端启用 HSTORE 支持。 |
bool |
FALSE |
postgres_json |
在客户端启用 JSON 支持。 |
bool |
FALSE |
postgres_uuid |
在客户端启用 UUID 支持。 |
bool |
TRUE |
如果 postgres_url 使用了 postgresql+srv 方案,将执行 SRV DNS 查找,并选择优先级最低但权重最高的记录以连接到 Postgres。
AWS 的 ECS 服务发现不遵循 SRV 标准,但创建 SRV 记录。如果 postgres_url 使用了 aws+srv 方案,将执行 SRV DNS 查找,并将构建包含所有主机和端口组合的 URL,这些组合按照优先级和权重顺序排列,利用 libpq 的多主机支持。
需求
版本历史
可在 https://sprockets-postgres.readthedocs.org/en/latest/history.html 查找
项目详情
sprockets-postgres-1.8.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b733043c5dffbec8406ccd1aaa1194a6e5b50ce8504b0587ebee0370352e1280 |
|
MD5 | c8a8cf0d1df1accc5a26ab32e947c452 |
|
BLAKE2b-256 | da9cc09a5bed54ddb28cab22cd2e25442f0de4cf746f38f2fbb662e60689a3b2 |