Esempio n. 1
0
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
Esempio n. 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
Esempio n. 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
Esempio n. 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