def _get_conn():
    '''
    Return a postgres connection.
    '''
    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: %s', sys.exc_info()[0])
        return None
    return conn
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: %s' , sys . exc_info ( ) [ 0 ] ) return None return conn
Return a postgres connection.