How to use the turbodbc.Megabytes 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 / helpers.py View on Github external
def open_connection(configuration,
                    rows_to_buffer=None,
                    parameter_sets_to_buffer=100,
                    **turbodbc_options):
    dsn = configuration['data_source_name']
    prefer_unicode = configuration.get('prefer_unicode', False)
    read_buffer_size = turbodbc.Rows(rows_to_buffer) if rows_to_buffer else turbodbc.Megabytes(1)

    options = turbodbc.make_options(read_buffer_size=read_buffer_size,
                                    parameter_sets_to_buffer=parameter_sets_to_buffer,
                                    prefer_unicode=prefer_unicode,
                                    **turbodbc_options)
    connection = turbodbc.connect(dsn, turbodbc_options=options, **get_credentials(configuration))

    yield connection
    connection.close()