chore: compose postgres conn settings in the same way as with mariadb

This commit is contained in:
David Arnold 2023-06-13 16:48:34 -05:00 committed by David Arnold
parent 731e5175e7
commit d5a390cd95
No known key found for this signature in database
GPG key ID: AB15A6AF1101390D

View file

@ -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