mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Merge pull request #181 from zalando/bugfix/acceptance-tests-connection-string
Do not assume that connection user is postgres, but take it from config.yml
This commit is contained in:
@@ -115,7 +115,9 @@ class PatroniController(AbstractController):
|
||||
|
||||
config['postgresql']['listen'] = config['postgresql']['connect_address'] = '{0}:{1}'.format(host, self.__PORT)
|
||||
|
||||
self._connstring = 'host={0} port={1} dbname=postgres user=postgres'.format(host, self.__PORT)
|
||||
user = config['postgresql'].get('superuser', {})
|
||||
self._connkwargs = {k: user[n] for n, k in [('username', 'user'), ('password', 'password')] if n in user}
|
||||
self._connkwargs.update({'host': host, 'port': self.__PORT, 'database': 'postgres'})
|
||||
|
||||
config['postgresql'].update({'name': name, 'data_dir': self._data_dir})
|
||||
config['postgresql']['parameters'].update({
|
||||
@@ -141,7 +143,7 @@ class PatroniController(AbstractController):
|
||||
|
||||
def _connection(self):
|
||||
if not self._conn or self._conn.closed != 0:
|
||||
self._conn = psycopg2.connect(self._connstring)
|
||||
self._conn = psycopg2.connect(**self._connkwargs)
|
||||
self._conn.autocommit = True
|
||||
return self._conn
|
||||
|
||||
|
||||
Reference in New Issue
Block a user