Skip to content

fix: expose autocommit parameter on ODBCConnector - #78

Merged
robd518 merged 2 commits into
developfrom
fix/odbc-autocommit-param
Aug 14, 2026
Merged

fix: expose autocommit parameter on ODBCConnector#78
robd518 merged 2 commits into
developfrom
fix/odbc-autocommit-param

Conversation

@robd518

@robd518 robd518 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

ODBCConnector called pyodbc.connect(conn_str) with no autocommit argument, so pyodbc used its default of False and issued SQL_ATTR_AUTOCOMMIT = OFF as part of connecting. Drivers for databases with no transaction support reject that, and the connection fails outright.

Because the rejection happens during pyodbc.connect(), there was no workaround — setting connector.conn.autocommit = True afterward is too late, as the failing call has already happened.

This adds an autocommit argument to ODBCConnector.__init__, passed straight through to pyodbc.connect().

Behavior

Defaults to False, matching pyodbc's own default, so existing behavior is unchanged. The parameter is appended after logger, keeping positional calls compatible.

Found while connecting to BigQuery over an ODBC DSN, where autocommit=True is required.

Tests

  • Updated test_odbcconnector_init, which asserted on the exact connect call args
  • Added a case pinning the default to False
  • Added a case confirming True propagates

poetry run pytest --ignore=dev_env → 192 passed.

Release

Patch bump — run the Release workflow with bump: patch after merge.

🤖 Generated with Claude Code

robd518 and others added 2 commits August 14, 2026 09:36
pyodbc defaults to autocommit=False, which makes it issue
SQL_ATTR_AUTOCOMMIT = OFF during connect. Drivers for databases without
transaction support reject that outright, so the connection fails before
a connection object exists to mutate.

Add an autocommit argument to ODBCConnector.__init__ that is passed
through to pyodbc.connect(). Defaults to False to match pyodbc, so
existing behavior is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@robd518
robd518 merged commit 135bf47 into develop Aug 14, 2026
2 checks passed
@robd518
robd518 deleted the fix/odbc-autocommit-param branch August 14, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant