def _get_conn():
    try:
        conn = psycopg2.connect(
               host=__opts__['master_job_cache.postgres.host'],
               user=__opts__['master_job_cache.postgres.user'],
               password=__opts__['master_job_cache.postgres.passwd'],
               database=__opts__['master_job_cache.postgres.db'],
               port=__opts__['master_job_cache.postgres.port'])
    except psycopg2.OperationalError:
        log.error("Could not connect to SQL server: " + str(sys.exc_info()[0]))
        return None
    return conn
Return a postgres connection.
dataset/ETHPy150Open saltstack/salt/salt/returners/postgres_local_cache.py/_get_conn