Created
August 28, 2019 19:53
-
-
Save sbalnojan/57a19108f6b6f700202e68884725bf35 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import os | |
from sqlalchemy import create_engine, func | |
from sqlalchemy.orm.session import sessionmaker | |
import psycopg2 | |
import logging | |
def get_db_connection(): | |
PGHOST = os.getenv("DB_HOST","localhost") | |
PGDATABASE = "postgres" | |
PGUSER = "postgres" | |
PGPASSWORD = "" | |
PGPORT = "5432" | |
conn_string = "postgresql://" + PGUSER + PGPASSWORD + "@" + PGHOST + ":" + PGPORT + "/" + PGDATABASE | |
conn = psycopg2.connect(conn_string) | |
return conn | |
def test_sql(): | |
conn = get_db_connection() | |
cursor = conn.cursor() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment