Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using DSN with SQLDriverConnect does not use the DSN settings #48

Open
Wonixen opened this issue Dec 27, 2024 · 3 comments
Open

Using DSN with SQLDriverConnect does not use the DSN settings #48

Wonixen opened this issue Dec 27, 2024 · 3 comments

Comments

@Wonixen
Copy link

Wonixen commented Dec 27, 2024

I have a DSN MyDuckDb where I have 4 keys:
database -> "c:\dataPath\myDuckDb.ddb"
driver -> "C:\Windows\System32\duckdb_odbc.dll"
debug_window_mode -> "window"
debug_skip_checkpoint_on_commit -> "yes"

when using SQLDriverConnect I use: "DSN=MyDuckDb", but it always connect to :memory:, and does not take into account the other two settings: debug_window_mode and debug_skip_checkpoint_on_commit.

staticlibs added a commit to staticlibs/duckdb-odbc that referenced this issue Jan 26, 2025
When connection string includes a trailing comma, existing impl in
Connect::ParseInputStr was doing an early exit without setting DSN
value to dbc->dsn. Because of this DSN was not used and default
:memory: instance was created.

The problem is not OS specific, but was happening on Windows all the
time because Windows ODBC Driver Manager is appending comma to the
passed connection string when calling SQLDriverConnect.

test_connect_odbc was extended to cover the trailing comma and also
parameters overriding in connection string.

Fixes: duckdb#29, duckdb#48
staticlibs added a commit to staticlibs/duckdb-odbc that referenced this issue Jan 26, 2025
When connection string includes a trailing comma, existing impl in
Connect::ParseInputStr was doing an early exit without setting DSN
value to dbc->dsn. Because of this DSN was not used and default
:memory: instance was created.

The problem is not OS specific, but was happening on Windows all the
time because Windows ODBC Driver Manager is appending comma to the
passed connection string when calling SQLDriverConnect.

test_connect_odbc was extended to cover the trailing comma and also
parameters overriding in connection string.

Fixes: duckdb#29, duckdb#48
@staticlibs
Copy link
Contributor

I think this is a duplicate of #29.

@Wonixen
Copy link
Author

Wonixen commented Jan 26, 2025

Yes and no, like #29 it does not use the database name, but it does not read the other settings. so the problem is bigger that what #29 seems to implied.
Maybe #29 could be modified to also mention that any setting in ODBC.ini are ignored!

@staticlibs
Copy link
Contributor

Yes, this is correct for #29 too, if the connection string ends with a semicolon (that is always true on Windows), then the DSN value is not set internally and DSN configuration from registry (HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI) is not loaded at all. So this is likely to be the same problem as #29.

staticlibs added a commit to staticlibs/duckdb-odbc that referenced this issue Feb 1, 2025
When connection string includes a trailing comma, existing impl in
Connect::ParseInputStr was doing an early exit without setting DSN
value to dbc->dsn. Because of this DSN was not used and default
:memory: instance was created.

The problem is not OS specific, but was happening on Windows all the
time because Windows ODBC Driver Manager is appending comma to the
passed connection string when calling SQLDriverConnect.

test_connect_odbc was extended to cover the trailing comma and also
parameters overriding in connection string.

Fixes: duckdb#29, duckdb#48
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

No branches or pull requests

2 participants