def get_connection():
    dbname = DATABASES['default']['NAME']
    pw = DATABASES['default']['PASSWORD']
    user = DATABASES['default']['USER']
    host = DATABASES['default']['HOST']
    port = DATABASES['default']['PORT']
    if not host:
        host = 'localhost'
    if not port:
        port = 5432
        
    conn_string = "host='%s' dbname='%s' user='%s' password='%s' port='%s'" % (host, dbname, user, pw, port)
    conn = psycopg2.connect(conn_string)
    return conn
dataset/ETHPy150Open sunlightlabs/read_FEC/fecreader/formdata/utils/db_utils.py/get_connection/original