theory
theory

Reputation: 9897

How do I configure a default driver for UnixODBC?

I would like to configure my odbc.ini and odbcinst.ini files to allow a default driver to be used if no driver is specified by the connection. I assume it's possible given the common error message when no driver is specified:

[unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)

But my DuckDuckGo-foo fails me. I tried setting a [DEFAULT] in odbc.ini:

[DEFAULT]
Driver=Snowflake

But still got the error (Due to the remainder of the configuration, "Snowflake" is a valid driver that works when I specify it.) I tried also adding a [DEFAULT] section to odbcinst.ini, but it made no difference.

So how does one go about specifying a default UnixODBC driver?

Upvotes: 0

Views: 3384

Answers (2)

theory
theory

Reputation: 9897

Based on the discussion on @TallTed's pull request I've come to the conclusion that it is not possible to configure a default driver in the unixODBC configuration files, sadly, despite the assertions of the ODBC default driver subkey, which I think @TallTed properly interprets in their answer. Perhaps in the future, but for now, at least, I think I have simply misunderstood the meaning of the error message:

Data source name not found, and no default driver specified

I had been assuming that this meant that no default driver was configured on the host. But I think now perhaps, what it actually means is "Cannot find the DSN in the URL, and there was no Driver param to fall back on, either". IOW, the Driver param specifies the default driver if the DSN can't be found.

That interpretation is consonant with the findings discussed in the PR. It's a little disappointing, but I think it could be fixed by an improved error message, or at least some sort of documentation update to explain how to specify a default driver.

Upvotes: 1

TallTed
TallTed

Reputation: 9444

Given your existing configuration files (both odbcinst.ini and odbc.ini), I believe you'll find success by adding the following (as described in the ODBC spec) to odbcinst.ini --

[Default]
Driver=Snowflake

-- and the following (as described in the ODBC spec) to odbc.ini --

[Default]
Description=SnowflakeDB
Driver=Snowflake
Locale=en-US
SERVER=SF_ACCOUNT.snowflakecomputing.com
PORT=443
SSL=on
ACCOUNT=SF_ACCOUNT

Upvotes: 0

Related Questions