From d5a390cd95aa4a66e3aeb9bd10c15fa08201f448 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 13 Jun 2023 16:48:34 -0500 Subject: [PATCH] chore: compose postgres conn settings in the same way as with mariadb --- frappe/database/postgres/database.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frappe/database/postgres/database.py b/frappe/database/postgres/database.py index edb2dc745a..f0a75e2e68 100644 --- a/frappe/database/postgres/database.py +++ b/frappe/database/postgres/database.py @@ -160,11 +160,16 @@ class PostgresDatabase(PostgresExceptionUtil, Database): return LazyDecode(self._cursor.query) def get_connection(self): - conn = psycopg2.connect( - "host='{}' dbname='{}' user='{}' password='{}' port={}".format( - self.host, self.user, self.user, self.password, self.port - ) - ) + conn_settings = { + "user": self.user, + "dbname": self.user, + "host": self.host, + "password": self.password, + } + if self.port: + conn_settings["port"] = self.port + + conn = psycopg2.connect(**conn_settings) conn.set_isolation_level(ISOLATION_LEVEL_REPEATABLE_READ) return conn