-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into train-test-split-updates
- Loading branch information
Showing
8 changed files
with
135 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
"""Postgres helper | ||
Author(s): | ||
Author(s): | ||
Wassym Kalouache ([email protected]) | ||
Carl Anderson ([email protected]) | ||
""" | ||
import os | ||
import psycopg2 | ||
from primrose.readers.database_helper import get_env_val | ||
|
||
try: | ||
import psycopg2 | ||
HAS_PSYCOPG2 = True | ||
|
||
except ImportError: | ||
HAS_PSYCOPG2 = False | ||
|
||
|
||
class PostgresHelper(): | ||
''' | ||
some utility methods for connecting to postgres | ||
|
@@ -43,6 +50,9 @@ def create_db_connection(): | |
db (connection): postgres db object | ||
""" | ||
if not HAS_PSYCOPG2: | ||
raise ImportError("psycopg2 is necessary to establish connection") | ||
|
||
host, port, username, password, database = PostgresHelper.extract_postgres_credentials() | ||
conn = psycopg2.connect(dbname=database, user=username, password=password, host=host, port=port, sslmode='require') | ||
return conn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters