Unable to Connect to Database using Custom Connection String with ODBC.jl - odbc

I'm having trouble connecting to a database with the ODBC.jl package. I can't tell if the problem is with my setup (more likely) or the package. The problem is that ODBC.jl can't seem to locate the correct ODBC driver.
> using ODBC
> ODBC.listdrivers()
/path/to/generic/odbc/
But I need to use a different driver than the one picked up from above.
I'm trying to use a custom connection string as follows:
>ODBC.DSN("DRIVER=path/to/driver/i/want;SERVER=myserver;USER=myuser;PASSWORD=mypass;DATABASE=somedb;")
which returns this:
[ODBC] IM002: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
ERROR: ODBC.ODBCError("ODBC.API.SQLDriverConnect(dbc,window_handle,conn_string,out_conn.ptr,BUFLEN,out_buff,driver_prompt) failed; return code: -1 => SQL_ERROR ")
My understanding is that I should be able to specify the driver as done above, but this does not give the desired connection.
I have .odbc.ini and .odbcinist.ini files set-up in my home directory, which I believe are working correctly. I'm on a Suse enterprise distro. When connecting via isql i have no problems.
Any help is appreciated.

Related

Connecting Oracle to R issue

I am trying to connect Oracle to RStudio using the "ROracle" package. I've installed the package and loaded it. I also have the "DBI" package installed and loaded.
I am using dbConnect(dbDriver("Oracledrivername"),oracle_schema,oracle_password,dbname="dbname") to connect to my oracle schema but I am getting this error:
Error in h(simpleError(msg,call)):
eror in evaluating the argument 'drv' in selecting a method for function 'dbConnect'
I then tried to narrow it down by testing dbDriver("Oracledrivername") by itself and the Error I get is:
Error: Couldn't find driver Oracledrivername
Things that I have done to attempt to fix this are:
I tested my connection to "Oracledrivername" in the ODBC data source administrator, the connection was ok.
The Rstudio I am using is 64 bit, Oracle client is a v12.1.0 64 bit, and the ODBC driver was set up on 64 bit
I have set the oracle_home location to C:\ORACLE12_64BIT\product\12.1.0\client_1

Add Snowflake ODBC connection in /etc/odbc.ini

I'm attempting to set up an ODBC connection on an EC2 server on our companies network. Have been reading Snowflake documentation here.
Following the documentation, I used yum to download and install the driver by adding a file /etc/yum.repos.d/snowflake-odbc.repo and then populating it with:
[snowflake-odbc]
name=snowflake-odbc
baseurl=https://sfc-repo.snowflakecomputing.com/odbc/linux/2.22.1/
gpgkey=https://sfc-repo.snowflakecomputing.com/odbc/Snowkey-37C7086698CB005C-gpg
I then ran yum install snowflake-odbc
This appears to have added a connection to our existing /etc/odbc.ini file:
[snowflake]
Description=SnowflakeDB
Driver=SnowflakeDSIIDriver
Locale=en-US
SERVER=SF_ACCOUNT.snowflakecomputing.com
PORT=443
SSL=on
ACCOUNT=SF_ACCOUNT
Chancing my luck I tested this connection in it's current format but it doesn't work. Seems I need to locate some more info / name value pairs and I'm unsure where to get them:
Driver= wants a path to a .so file that I thought would have been installed with my steps outlined above. Not sure where to find this file or what path to use?
When I tested the connection the error I received said I was missing a UID.
The section of the documentation on dns entries has additional details of which settings can be added to odbc.ini, including an example
Driver = /usr/jsmith/snowflake_odbc/lib/libSnowflake.so
Description =
server = yz23456.us-east-1.snowflakecomputing.com
role = analyst
database = sales
warehouse = analysis
Does anyone know where can I find out which settings I need to add to get the odbc connection to work?

SQLBase error HY092

I'm trying to config a connection with SQLBase with odbc driver on Windows and I never did that, but I'm getting the error:
Connection failed with SQL State: "HY092"
I'm using the Windows ODBC Administrator to try add the connection. In the field "Config Filename (INI)" of the configuration screen I put: "C:\Program Files (x86)\Centura\sql.ini" and I add "C:\Program Files (x86)\Centura\" to the PATH system variable.
In the application (.NET) I'm getting the message:
ERROR [HY092] [Gupta][ODBC Driver]Invalid attribute/option identifier
My sql.ini file has the content:
[win32client]
clientname=CWBXXX
[win32client.dll]
comdll=sqlws32
[win32client.
serverpath=server3,<SERVER_IP>,2155/<BASE_NAME>
Anyone could help me? Thank you.
Good to see you are using SQLBase . Awesome.
Two important settings to get right.
1) Make sure you are using the correct ODBC administrator
I'm guessing 32 bit in %systemdrive%\Windows\SysWoW64\odbcad32.exe.
If not , use the 64bit one in %systemdrive%\Windows\System32\odbcad32.exe.
Under System DSN tab Add the correct driver for the database. Either 'Centura SQLBase 3.6 32bit Driver' or the 'Gupta SQLBase 12.x' driver if you are running SQLBase 12.
Under the Configure Tab, specify the Data Source Name that you will use in your sql.ini. THEY MUST MATCH.
2)a. Make sure you only ever have 1 sql.ini on the client. Ever.
2)b. sql.ini needs the ODBC driver specified in the client section:
[win32client.dll]
comdll=sqlodb32
[odbcrtr]
odbctrace=off
longbuffer=32767
buffrow=10000
remotedbname=[dB Name specified in ODBC] ,
DSN=[Data Source Name specified in ODBC]
(without the square brackets eg. remotedbname=MyDatabase,DSN=MyDatasetName whatever names you have specified in ODBC admin.)

Connecting to Vertica database via pyodbc without odbc.ini on RHEL6

I do not have the permission to edit the system-wide odbc.ini file, therefore I am searching for alternative ways to specify connection parameters towards Vertica.
I have unpacked the needed libraries to a certain location, and am attempting to create a connection string from my "custom" config file.
Is it possible to explicitly specify the path to the driver (and any other necessary parameters) when using pyodbc.connect?
Example intention (fails with the error below):
conn = pyodbc.connect("DRIVER=path/to/libverticaodbc.so;...")
Error:
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')
Alternatively, is there another option to use odbc.ini files other than the ones at /etc/, e.g. through setting an environment variable?
I recommend to avoid the use of ODBC driver to connect to Vertica .
Vertica release native driver for python , see attach full details and examples :
https://github.com/uber/vertica-python
I hope you will find it us-full
Thanks
You can put a file called .odbc.ini in your home directory which will be for user specific ODBC settings.
http://www.unixodbc.org/odbcinst.html

How can I connect to a sqlite3 db using pyodbc and unixODBC?

I can't figure out how to connect to a sqlite db using pyodbc. I have a DSN set up and can connect to it via isql without problems.
isql -v TEST
works like a charm, However
import pyodbc
pyodbc.connect('DSN=TEST')
Gives the following error message:
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')
I also tried a great amount of permutations of the connection strings in the examples at https://code.google.com/p/pyodbc/wiki/GettingStarted to no avail.
pyodbc.dataSources()
Does list the dsn I'm trying to connect to with the value holding the path to libsqlite3odbc.so
I assume I am missing something obvious, but I can't figure out what...
EDIT: Using unixODBC 2.3.0, python 2.7.1, sqliteodbc 0.88 and pyodbc 2.1.8
EDIT: The reason I want to use pyodbc is for portability to Windows and MS Access
Just to check what is being passed to the driver manager, turn on ODBC tracing, in your odbcinst,ini file add
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
Then run the app again and see what is being passed to the SQLConnect or SQLDriverConnect call.

Resources