I'm trying to connect an Azure SQL instance to my R Studio Server that is served on Ubuntu.
library(DBI)
library(odbc)
con_string <- paste(c('DRIVER', "PORT", "SERVER", "DATABASE", "UID", "PWD"),
c('{ODBC Driver 17 for SQL Server}', 1433,
"mydatabase.database.secure.windows.net", "DB1",
"me", "foo"),
sep = "=", collapse = ";")
con <- DBI::dbConnect(odbc::odbc(), .connection_string = con_string)
The error I get:
Error: nanodbc/nanodbc.cpp:950: 01000: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found
I've tried all of the other drivers:
{ODBC Driver 17 for SQL Server}
{ODBC Driver 13 for SQL Server}
I can't connect. I've used pyodbc in other environments and been able to connect with the same string.
I confirm that the ODBC libraries are installed:
ubuntu#ip-1-2-3-4:~$ sudo apt-get install unixodbc unixodbc-dev --install-suggests
Reading package lists... Done
Building dependency tree
Reading state information... Done
unixodbc is already the newest version (2.3.1-4.1).
unixodbc-dev is already the newest version (2.3.1-4.1).
The following packages were automatically installed and are no longer required:
linux-aws-headers-4.4.0-1048 linux-aws-headers-4.4.0-1049 linux-headers-4.4.0-1048-aws linux-headers-4.4.0-1049-aws linux-image-4.4.0-1048-aws
linux-image-4.4.0-1049-aws
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 107 not upgraded
.It appears that the drivers are not available from within my R environment or I'm calling it the wrong thing. This is the R Server docs that I'm reading
The Problem doesn't comes from the unix-odbc lib.
Indeed as you can see in this:
[unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found
2 Solutions are to try:
The problem is the driver is not found. It can be due because your driver is not correctly installed in your computer. Verify you followed the installation step.
It can also be caused by a missing -Wl,-rpath,<Link to your gcc driver library> option in the compilation of your C++ application. But as the R Language is written in C this should not influence you.
Related
I'm having issues getting the ODBC driver for Snowflake to work on an M1 Apple Silicon Mac running Big Sur.
Successfully following the instructions on Snowflake's website gets me to the point where testing the driver from the command line (using iodbctest) using the DSN results in the following error:
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib, 6): no suitable image found. Did find:
/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib: no matching architecture in universal wrapper
/opt/snowfl (0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003
My Snowflake driver is installed to /opt/snowflake/snowflakeodbc, so that is correct -- I'm suspicious that this is specifically an M1 problem. I'm using the 2.24.1 version of the driver available from the download mirror here, and the path to the driver in /etc/odbcinst.ini is /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib (which exists and seems, from all my research, that it should be right).
When I run a connection via DBI in R, I get a completely different error:
Error: nanodbc/nanodbc.cpp:1021: 00000:
[Snowflake][ODBC] (11560) Unable to locate SQLGetPrivateProfileString function.
In other StackOverflow posts, people have referenced the above error meaning that there is a missing library of some kind (IODBC isn't configured correctly?), but I've tried quite a few things to no avail. Any guidance would be great.
Tinkered with this a bit more and realized it's an artifact of the installation pathways for the .dmgs & the preset paths in simba.snowflake.ini.
You need to point the Snowflake driver towards the iODBC dylib (as per a sideswiping statement in the docs) -- the driver is originally configured to look for the ODBC dylib (not iODBC) in a folder that's on the path.
When you install the iODBC driver, verify that it is installed to /usr/local/iODBC (this was where my Silicon Mac installed it to) -- and that /usr/local/iODBC/lib has libiodbc.dylib in it. If so, navigate to your installed snowflake driver directory (should be /etc/snowflake) and alter the simba.snowflake.ini file (/etc/snowflake/snowflake/snowflakeodbc/universal/simba.snowflake.ini). You want to uncomment & alter the last line to be both uncommented & point with a full path towards the iODBC dylib (instead of the default, which is the ODBC dylib).
# Darwin specific ODBCInstLib
# iODBC
ODBCInstLib=/usr/local/iODBC/lib/libiodbcinst.dylib
Make sure to comment out any other ODBCInstLib line so that only one is configured. That should enable you to get your connection to snowflake up and running on an M1 Mac.
Big Sur is macOS v11.n
Snowflake supports macOS 10.14 and 10.15 Supported OSs
So what you are trying to do is not supported and is unlikely to work
None of the other solutions worked for me but #kiran-kumawat 's answer set me down a path that worked.
It seems like the core of the issue is that the odbc code is looking for arm64 architecture drivers but Snowflake is providing it in x86_64 architecture. By installing an x86_64 versions of odbc we are able to have it successfully talk to the driver.
First I uninstalled R and Rstudio. (it may be possible to sim-link or change things behind the scenes to make this work with existing installs but I am not sure).
Then install rosetta (apples software for translating between architectures) and a version of homebrew built with it. I am leaving my main version of homebrew in place.
softwareupdate --install-rosetta
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then use that version of homebrew to install odbc, R, and Rstudio.
arch -x86_64 /usr/local/Homebrew/bin/brew install unixodbc
arch -x86_64 /usr/local/Homebrew/bin/brew install --cask rstudio
arch -x86_64 /usr/local/Homebrew/bin/brew install --cask r
We then need to install the snowflake driver: https://sfc-repo.snowflakecomputing.com/odbc/mac64/latest/index.html
Click through all the install prompts.
Modify your files
/usr/local/etc/odbcinst.ini:
[Snowflake Driver]
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
/usr/local/etc/odbc.ini
[Snowflake]
Driver = Snowflake Driver
uid = <uid>
server = <server>
role = <role>
warehouse = <warehouse>
authenticator = externalbrowser
We also need to modify the simba.snowflake.ini file.
It is somewhat locked down so run:
sudo chmod 646 /opt/snowflake/snowflakeodbc/lib/universal/simba.snowflake.ini
Then
vim /opt/snowflake/snowflakeodbc/lib/universal/simba.snowflake.ini
And find the ODBCInstLib line that is uncommented and change it to:
ODBCInstLib=/usr/local/Cellar/unixodbc/2.3.9_1/lib/libodbcinst.dylib
After setting this up I was able to use this connection successfully:
install.packages("DBI")
install.packages("odbc")
con <- DBI::dbConnect(odbc::odbc(), "Snowflake")
one of our team member suggested below steps and it worked for us for Apple M1 series
Install the latest snowflake driver
Uninstall m1 based homebrew using cmd
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
Install intel based homebrew - restart terminal when done
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Re-install unixodbc
arch -x86_64 brew install unixodbc
Test
isql -v Pattern
in your database.yml file for connection to snowflake make following change-
replace "dsn: <DSN_NAME>" with following
conn_str: "Driver={PATH};Locale=en-US;uid={USER_NAME};pwd= {PASSWORD};server=<yours>.snowflakecomputing.com;role=<ROLE>;charset=UTF-8;warehouse=<WAREHOUSE>;database=<DATABASE>;schema=<SCHEMA>;"
Has anyone gotten this to work? I use excel w odbc to refresh snowflake files and have tried multiple ways to move the drivers etc and followed snowflake instructions but never works. I did get parallels to work running windows arm but would prefer to just do this in Mac OS
I also have a M1 (version Monterey 12.0) and I ran into similar issues when I tested the driver. Nevertheless, when I tried the "real connection" it worked like a charm. So, maybe it would be good for you to go and test the "real connection" to avoid a wasting of time using such testing. Hope you find this useful.
I have created an R package that I have hosted in my company's Gitlab, and when I try to use the solution described here to install it I get the following error:
Installation failed: Error in 'git2r_clone': SSL error: syscall failure: Connection reset by peer
A coworker tried to run the same command I did and they managed to do it. Why is this error occurring to me?
Check your Git version and your %PATH% (Windows) or $PATH.
You must have a recent Git, for supporting the right OpenSSL version, and you must not reference any other openssl in your PATH which might be too old.
I was successfully connecting to Teradata from R with the following code:
library(DBI)
library(rJava)
library(RJDBC)
library(teradataR)
drv = JDBC("com.teradata.jdbc.TeraDriver","/Users/me/R_repos/TeraJDBC_indep_indep.14.10.00.26/terajdbc4.jar:/Users/me/R_repos/TeraJDBC_indep_indep.14.10.00.26/tdgssconfig.jar")
However it has suddenly stopped working. I now get this error message when I run the above JDBC function:
Error in .jfindClass(as.character(driverClass)[1]) : class not found
I have not changed the directory path or the jar files in any way.
When I run .jclassPath() I see my RJDBC jar and JAVA jar loading correctly:
[1] "/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/java" "/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RJDBC/java/RJDBC.jar"
Nothing else has changed except that I have restarted my R session several times and also installed the Caret package recently as well. I cannot understand why this is failing.
I'm running R version 3.2.2 on Mac iOS 10.10.5
Is it possible that your JVM version has changed? One of the most common reasons for this error is JVM mismatch. At any rate, run
.jclassLoader()$setDebug(1L)
to see the actual reason it's failing.
And run
("java.lang.System")$getProperty("java.version")
to check your JVM version.
Download Teradata JDBC drivers from here:
https://downloads.teradata.com/download/connectivity/jdbc-driver
jars=['/CorrectPath/tdgssconfig.jar','/CorrectPAth/terajdbc4.jar']
Unpack and give the new path for jar files. It should work.
I am trying to install teradata utilities 15.x,
I earlier installed teradata ODBC drive and .NET Data Provider for teradata.
Now if I start the installation, I get an error saying:
"The installation failed for the following reason:
A TTU 14.0 suite is installed. Please uninstall all TTU 14.10 suites before installing TTU 15.00"
I tried to uninstall the suite using uninstall_TTU.vbs, but I get below error:
TTUSuiteSilent.exe was not found in .\TTU directory.
This script needs TTUSuiteSilent.exe to remove suite packages.
Aborting uninstallation....
Any advise on how to get this uninstalled?
The Teradata ODBC driver typically requires three components to be installed on the client:
ICU Libraries
GSS Libraries
ODBC Driver
You must ensure that all three of these have been removed before you can replace them with another version. Typically, they can be found in the Add/Remove Programs applet of the Windows Control Panel.
This is a follow on to How to install ROracle package on Windows 7?
I'm getting the following error trying to build ROracle
** testing if installed package can be loaded
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'D:/Users/a101/Documents/R/win-library/3.0/ROracle/libs/x64/ROracle.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
I have RTools and 64-bit Oracle Instantclient installed
I execute the following from an Admin privieledged command line:
set OCI_LIB64=C:/Oracle/instantclient_12_1_x64
set OCI_INC=C:/Oracle/instantclient_12_1_x64/sdk/include
"C:/Program Files/R/R-3.0.0/bin/x64/R" CMD INSTALL --build ROracle_1.1-10.tar.gz
I've searched around and what I've found says this error is caused by building in mixed mode. I.e. 32-bit R with 64-bit Oracle client library or vice versa. I've been looking at this for many (many) hours and I believe I'm using all 64-bit (OS, R, Oracle client library). All the trace messages seem to indicate 64-bit everywhere. Any thoughts on what I might be missing?
To run dependency walk use Dependecy Walker, choose opening ROracle.dll in this app. I had the same issue since ROracle.dll was searching for OCI x64 (Oracle client), whereas I had x86 version of it installed on my PC.
I came across the same question, with 64bit windows and R...
Since I shifted the ROracle from 32bit to 64bit some days before. After changing the OCI_LIB64, OCI_INC and also add the 64bit instantclient dir to the env variable Path, it works fine in R and RStudio.
But I set up a task scheduler before, using Rscript.exe to run a RCode every day. That task failed since the shift with the same error:"Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared object 'E:/app/R_lib/3.4/ROracle/libs/x64/ROracle.dll': LoadLibrary failure: %1 is not a valid Win32 application."
My final solution is to restart the computer...And the task scheduler works again....guess there should be some 32bit file stored temporarily and need to be deleted before using 64bit ROracle...
You need to add the Oracle Client 32 and 64 bits witk SDK folder directory to the Windows System enviromental variables path. Also need to install rjava package (install java 64 bits) and set JAVA_HOME in R sys.setenv().
install.packages("rJava") #Install Java 64 bits
library(rJava) #Not Errors
Sys.setenv("OCI_LIB64"="C:/instantclient_12_2_64bits")
Sys.setenv("OCI_LIB32" = "C:/instantclient_12_2_64bits")
Sys.setenv("ORACLE_HOME" = "C:/instantclient_12_2_64bits")
Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_241')
install.packages(paste0(path,"/ROracle_1.3-1.tar.gz"), repos = NULL, type = "source")
library(ROracle)
The last message in the install process should be DONE!
In the Windows System enviromental path:
C:\instantclient_12_2_64bits;
C:\instantclient_12_2_64bits\sdk;
C:\instantclient_12_2_32bits;
C:\instantclient_12_2_32bits\sdk;
hope this works!