How to use the turbodbc.DatabaseError function in turbodbc

To help you get started, we’ve selected a few turbodbc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blue-yonder / turbodbc / python / turbodbc_test / test_connection.py View on Github external
def test_no_autocommit(dsn, configuration):
    connection = connect(dsn, **get_credentials(configuration))

    connection.cursor().execute('CREATE TABLE test_no_autocommit (a INTEGER)')
    connection.close()

    connection = connect(dsn, **get_credentials(configuration))
    with pytest.raises(DatabaseError):
        connection.cursor().execute('SELECT * FROM test_no_autocommit')
github blue-yonder / turbodbc / python / turbodbc_test / test_connection.py View on Github external
def test_rollback(dsn, configuration):
    connection = connect(dsn, **get_credentials(configuration))

    connection.cursor().execute('CREATE TABLE test_rollback (a INTEGER)')
    connection.rollback()

    with pytest.raises(DatabaseError):
        connection.cursor().execute('SELECT * FROM test_rollback')
github blue-yonder / turbodbc / python / turbodbc_test / test_cursor_basics.py View on Github external
def test_insert_duplicate_uniquecol_raises(dsn, configuration):
    with open_cursor(configuration) as cursor:
        with query_fixture(cursor, configuration, 'INSERT DUPLICATE UNIQUECOL') as table_name:
            with pytest.raises(DatabaseError) as ex:
                cursor.execute("INSERT INTO {table_name} VALUES (1)".format(table_name=table_name))
                # some databases (e.g. exasol) report failure not in the execute statement above, but only
                # when closing the odbc handle, i.e. at cursor.close:
                cursor.close()
github blue-yonder / turbodbc / python / turbodbc_test / test_connect.py View on Github external
def test_connect_raises_on_invalid_additional_option(dsn, configuration):
    additional_option = {configuration['capabilities']['connection_user_option']: 'invalid user'}
    with pytest.raises(DatabaseError):
        connect(dsn=dsn, **additional_option)
github blue-yonder / turbodbc / python / turbodbc_test / test_connect.py View on Github external
def test_connect_raises_on_invalid_dsn():
    invalid_dsn = 'This data source does not exist'
    with pytest.raises(DatabaseError):
        connect(invalid_dsn)