Skip to content
Snippets Groups Projects
Commit 91f019bf authored by Jan David Mol's avatar Jan David Mol
Browse files

TAsk #8887: Provide connection options for psycopg2

parent ab196a4f
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,22 @@ class Credentials:
"dbname": self.database,
}
def psycopg2_connect_options(self):
"""
Returns a dict of options to provide to PsycoPG2's psycopg2.connect function. Use:
conn = psycopg2.connect(**dbcreds.psycopg2_connect_options())
"""
return {
"host": self.host,
"port": self.port or None,
"user": self.user,
"password": self.password,
"database": self.database,
}
def mysql_connect_options(self):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment