I am trying to run some queries in Oracle SQL through R using RODBC but it doesn't work, not matter what I try.
I installed the "basic", "sqlplus", "odbc" and "sdk" packages from Oracle (yes, I know sdk and sqlplus aren't strictly needed), did all the path settings needed, copied libodbcinst.2.dylib to the instant client folder, installed the odbc driver in odbcinst.ini, tried changing dynlib locations through install_name_tool, even tried adding "arch -x86_64" before the driver name on odbcinst.ini - all to no avail.
I am using a MacBook Air M1, macOS Monterey 12.3.1, unixodbc installed on opt/homebrew from homebrew...
The connection string is:
sqlDriver <- 'Oracle 19 ODBC driver'
connectionStringSQL <- paste0(
"Driver=", sqlDriver,
";Server=", sqlServer,
";Database=", sqlDatabase,
";Uid=", sqlUser,
";Pwd=", sqlPassword,
";Encrypt=yes",
";Port=1521")
conn <- odbcDriverConnect(connectionStringSQL)
But I don't think the connection string matters, because the error I get is:
Warning messages:
1: In odbcDriverConnect(connectionStringSQL) :
[RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver Manager]Can't open lib 'arch -x86_64 /Users/*****/instantclient/libsqora.dylib.19.1' : file not found
2: In odbcDriverConnect(connectionStringSQL) : ODBC connection failed
Related
I am trying to connect to Snowflake with R:
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
"SnowflakeDSII"
)
OR
con <- DBI::dbConnect(odbc::odbc(),
Driver = "Snowflake",
Server = "*.snowflakecomputing.com",
UID = "*",
PWD = "*",
Database = "*",
Warehouse = "*",
Schema = "PUBLIC"
)
But constantly get this error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib '/opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib' : file not found
I use iODBC Data Source Administrator to test the connection of DNS that I have setup and it says:
The connection DSN was tested successfully, and can be used at this time.
I am macOS Big Sur, Apple M1 chip with R 4.1.0
Update
content of the /Library/ODBC/odbcinst.ini:
[ODBC Drivers]
Snowflake = Installed
[Snowflake]
Driver = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Update 2
If I run the same script with Rscript under sudo, I get different error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Data source name not found and no default driver specified
Execution halted
The issue is a reference issues with the drivers... the 64-bit driver was probably installed 2nd. I'd remove both drivers and only install one.
I'm trying to connect R with an MS Access database on a Windows 7 64bit machine.
library(RODBC)
con <- odbcConnectAccess2007("M:/path/to/mydatabase/my.database.accdb")
# [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specifiedODBC connection failed
I've also tried package odbc using connection strings specified at https://www.connectionstrings.com/access/ but similarly cannot connect
library(DBI)
con <- dbConnect(drv = odbc::odbc(), dsn = "Microsoft Access Driver", driver = "Microsoft Access Driver (*.mdb, *.accdb)", database = "M:/path/to/mydatabase/my.database.accdb")
# Error: nanodbc/nanodbc.cpp:950: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
What am I doing wrong?
You can use my AceOdbcCheck script to test your machine for a valid install of Access "ACE" ODBC. If you don't have it installed you can download the drivers here.
Note that the "bitness" (64-bit or 32-bit) of the Access ODBC driver must match the version of R you are running. That is, if you are running 32-bit R then you need the 32-bit drivers even though you are running 64-bit Windows.
I might be re-asking the question but I am having difficulty creating connection to Oracle DB which is on a remote server. I am new to R and Oracle DB so I do not have much experience. I am using RStudio. I have installed RODBC package successfully. I am using Ubuntu 14.04 Operating System.
Firstly I use library RODBC
library("RODBC", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.0")
Then I have entered following command:
odbcConnect(dsn = "DatabaseName", uid = "UserID", pwd = "Password")
I get the following error:
[1] -1
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=DatabaseName;UID=UserID;PWD=Password") :
[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified
2: In RODBC::odbcDriverConnect("DSN=DatabaseName;UID=UserID;PWD=Password") :
ODBC connection failed
I have searched but I am not getting to anywhere. Please tell me process or steps to how I can make a connection.
Thank You!
I am using 32-bit R with RStudio to try and connect to an .accdb file. I have 32-bit MS Access running on my machine.
R version:
platform i386-w64-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 3
minor 1.2
...
language R
version.string R version 3.1.2 (2014-10-31)
nickname Pumpkin Helmet
I'm trying to use the RODBC package to connect to an MS Access database. I cannot use odbcConnectAccess("location_of_database.accdb") to connect to a database provided by a client. This particular database was created with Access 2013. When I try to connect, I get a variety of warning messages:
Warning messages:
1: In odbcDriverConnect(con, ...) :
[RODBC] ERROR: state HY000, code -1028, message [Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt.
2: closing unused RODBC handle 12
3: In odbcDriverConnect(con, ...) :
[RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x11a4 Thread 0x798 DBC 0x88e0064 Jet'.
4: In odbcDriverConnect(con, ...) :
[RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x11a4 Thread 0x798 DBC 0x88e0064 Jet'.
5: In odbcDriverConnect(con, ...) : ODBC connection failed
Interestingly, I can use odbcConnectAccess2007() to connect successfully to databases that were created with Access 2010; however, when I try to use odbcConnectAccess() to connect to those same databases, I get the same errors above.
A Google search of the Error: state 01000, code 1 message above suggests that this page may be helpful, but even after following the steps to alter the HKEY_LOCAL_MACHINE does not work.
While I originally thought that this question was promising, the warning message there relates to "ACE DSN" while the error messages I'm seeing relate to "Jet DSN."
I cannot open the databases I'm trying to access with RODBC with my version of Access as the databases were created with Access 2013 and I have Access 2010 installed.
Can anyone help me trouble shoot why I can't open this database with odbcConnectAccess()?
why I can't open this [Access 2013] database with odbcConnectAccess()?
I'm fairly certain that
odbcConnectAccess(<fileSpec>)
is simply shorthand for
odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=<fileSpec>')
(i.e., the older "Jet" ODBC driver), and
odbcConnectAccess2007(<fileSpec>)
is simply shorthand for
odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=<fileSpec>')
(i.e., the newer "ACE" ODBC driver).
The older "Jet" driver cannot work with .accdb files, so odbcConnectAccess2007() would be required. If that throws an "Unrecognized database format" error then it's likely that the database file is damaged.
This is my first time connecting to Vertica. I have already connected to a MySQL database sucessfully by using RODBC library.
I have the database setup in vertica and I installed the windows 64-bit ODBC driver from https://my.vertica.com/download-community-edition/
When I tried to connect to vertica using R, I get the below error:
channel = odbcDriverConnect(connection = "Server=myserver.edu;Database=mydb;User=mydb;Password=password")
Warning messages:
1: In odbcDriverConnect(connection = "Server=myserver.edu;Database=mydb;User=mydb;Password=password") :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect(connection = "Server=myserver.edu;Database=mydb;User=mydb;Password=password") :
ODBC connection failed
Can someone tell me how to fix this? Or is there any other ways to connect to vertica using R?
It may not be the fastest, but I prefer to use the Vertica JDBC driver from R. Getting the ODBC drivers working is a little messy across different operating systems. If you already have a Java Runtime Environment (JRE) installed for other applications then this is fairly straightforward.
Download the Vertica JDBC drivers for your Vertica server version from the MyVertica portal. Place the driver (a .jar file) in a reasonable location for your operating system.
Install RJDBC into your workspace:
install.packages("RJDBC",dep=TRUE)
In your R script, load the RJDBC module and create an instance of the Vertica driver, adjusting the classPath argument to point to the location and filename of the driver you downloaded:
library(RJDBC)
vDriver <- JDBC(driverClass="com.vertica.jdbc.Driver", classPath="full\path\to\driver\vertica_jdbc_VERSION.jar")
Make a new connection using the driver object, substituting your connection details for the host, username and password:
vertica <- dbConnect(vDriver, "jdbc:vertica://host:5433/db", "username", "password")
Then run your SQL queries:
myframe = dbGetQuery(vertica, "select Address,City,State,ZipCode from MyTable")
You have to use double slash in the classPath arguement in JDBC function.
for example,
vDriver <- JDBC(driverClass="com.vertica.jdbc.Driver",
classPath="C:\\Program Files\\Vertica Systems\\JDBC\\vertica-jdk5-6.1.2-0.jar")
worked for me, while just copying and pasting the route failed.