예제 #1
0
파일: rds.py 프로젝트: dkawase/nessie
def _get_cursor(autocommit=True, operation='write'):
    with get_psycopg_cursor(
        operation=operation,
        autocommit=autocommit,
        uri=app.config.get('SQLALCHEMY_DATABASE_URI'),
    ) as cursor:
        yield cursor
예제 #2
0
def _get_cursor(autocommit=True, operation='write'):
    try:
        with get_psycopg_cursor(
                operation=operation,
                autocommit=autocommit,
                **_connection_args(),
        ) as cursor:
            yield cursor
    except psycopg2.Error as e:
        _handle_psycopg2_error(e)
        yield None
예제 #3
0
def _get_cursor(operation):
    try:
        with get_psycopg_cursor(
            operation=operation,
            autocommit=True,
            uri=app.config.get('LRS_DATABASE_URI'),
        ) as cursor:
            yield cursor
    except psycopg2.Error as e:
        error_str = str(e)
        if e.pgcode:
            error_str += f'{e.pgcode}: {e.pgerror}\n'
        app.logger.warning({'message': error_str})
        yield None
예제 #4
0
def _get_cursor(autocommit=True, operation='write'):
    try:
        with get_psycopg_cursor(
            operation=operation,
            autocommit=autocommit,
            dbname=app.config.get('REDSHIFT_DATABASE'),
            host=app.config.get('REDSHIFT_HOST'),
            port=app.config.get('REDSHIFT_PORT'),
            user=app.config.get('REDSHIFT_USER'),
            password=app.config.get('REDSHIFT_PASSWORD'),
        ) as cursor:
            yield cursor
    except psycopg2.Error as e:
        error_str = str(e)
        if e.pgcode:
            error_str += f'{e.pgcode}: {e.pgerror}\n'
        app.logger.warning({'message': error_str})
        yield None