def _make_postgres_string(password):
"""Create postgres connection string.
It's parametrized, so it's possible to
create either quoted or unquoted version of connection string.
Note that it's outside of class since there is no simple way how to call it inside the class
without class initialization.
:param password: password which will be embedded into Postgres connection string
:return: fully working postgres connection string
"""
connection = 'postgresql://{user}:{password}@{pgbouncer_host}:{pgbouncer_port}' \
'/{database}?sslmode=disable'. \
format(user=environ.get('POSTGRESQL_USER'),
password=password,
pgbouncer_host=environ.get('PGBOUNCER_SERVICE_HOST', 'coreapi-pgbouncer'),
pgbouncer_port=environ.get('PGBOUNCER_SERVICE_PORT', '5432'),
database=environ.get('POSTGRESQL_DATABASE'))
return connection
defaults.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录