Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()