Skip to content

FEAT: Change default ODBC driver to v18 with v17 fallback and logging#493

Draft
bewithgaurav wants to merge 2 commits intodevfrom
bewithgaurav/odbc-v18-support
Draft

FEAT: Change default ODBC driver to v18 with v17 fallback and logging#493
bewithgaurav wants to merge 2 commits intodevfrom
bewithgaurav/odbc-v18-support

Conversation

@bewithgaurav
Copy link
Collaborator

  • Change default driver from 'ODBC Driver 17' to 'ODBC Driver 18'
  • Add automatic fallback to v17 if v18 driver is not found
  • Add warning log when fallback occurs with security recommendations
  • Refactor connection string building into separate method

- Change default driver from 'ODBC Driver 17' to 'ODBC Driver 18'
- Add automatic fallback to v17 if v18 driver is not found
- Add warning log when fallback occurs with security recommendations
- Refactor connection string building into separate method
- Add test_base.py with 45 tests covering:
  - encode_value()
  - encode_connection_string()
  - prepare_token_for_odbc()
  - handle_datetimeoffset()
  - DatabaseWrapper._is_driver_not_found_error()
- Add extras_require[test] with unittest-xml-reporting for Python 3.12+
@bewithgaurav bewithgaurav force-pushed the bewithgaurav/odbc-v18-support branch from f27ac64 to bb3b6a0 Compare February 6, 2026 09:45

def test_simple_connection_string(self):
"""Test basic connection string encoding."""
fields = {'DRIVER': 'ODBC Driver 18 for SQL Server', 'SERVER': 'localhost'}

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
fields = {'DRIVER': 'ODBC Driver 18 for SQL Server', 'SERVER': 'localhost'}
result = encode_connection_string(fields)
self.assertIn('DRIVER=ODBC Driver 18 for SQL Server', result)
self.assertIn('SERVER=localhost', result)

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test with multiple fields."""
fields = {
'DRIVER': 'ODBC Driver 18 for SQL Server',
'SERVER': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test basic connection string building."""
conn_params = {
'NAME': 'testdb',
'HOST': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
result = self.wrapper._build_connection_string(conn_params, driver)

self.assertIn('DRIVER=ODBC Driver 18 for SQL Server', result)
self.assertIn('SERVER=localhost', result)

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
result = self.wrapper._build_connection_string(conn_params, driver)

# Microsoft drivers use comma for port
self.assertIn('SERVER=localhost,1433', result)

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test connection string with DSN."""
conn_params = {
'NAME': 'testdb',
'HOST': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test connection string with trusted connection (no user/password)."""
conn_params = {
'NAME': 'testdb',
'HOST': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test connection string with extra parameters."""
conn_params = {
'NAME': 'testdb',
'HOST': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
"""Test that PASSWORD is not included with ActiveDirectoryInteractive auth."""
conn_params = {
'NAME': 'testdb',
'HOST': 'localhost',

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
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