JuliaDatabases / ODBC.jl

An ODBC interface for the Julia programming language
https://odbc.juliadatabases.org/stable
Other
106 stars 63 forks source link

Feature Request: Allow username and password to be specified in DSN #248

Closed metanoid closed 4 years ago

metanoid commented 5 years ago

On Windows, it is possible to store the username and password for a connectionstring as part of the DSN.

However, ODBC.DSN expects the username and password to be passed in along with the DSN.

The end result is that while this works in R:

library(odbc)
con = dbConnect(odbc(), "MyDSN")

This does not work in ODBC.jl:

using ODBC
con = ODBC.DSN("MyDSN")
ODBC.ODBCError("ODBC.API.SQLConnect(dbc, connectionstring, username, password) failed; return code: -1 => SQL_ERROR")
in top-level scope at untitled:4
in ODBC.DSN at ODBC\KFiOK\src\ODBC.jl:122
in DSN at ODBC\KFiOK\src\ODBC.jl:122 
in #DSN#3 at ODBC\KFiOK\src\ODBC.jl:57

Ideally, if the user has chosen not to specify a username and password, ODBC.DSN should check whether the username and/or password is available in the DSN.

metanoid commented 5 years ago

As per the error message, the problem appears to really reside in the ODBC.API.SQLConnect function.

quinnj commented 4 years ago

Thanks for making an issue on this; I've got a fix for this coming on master