I am using both the DBI and ODBC package in "R" in order to make a connection to an ORACLE database.
Here is the connection code I am using:
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "ORACLE",
Host = "orasada.ca",
SVC = "STG",
UID = "username",
PWD = "password",
Port = 1521)
Everything looks fine to me, but I keep getting this error:
Error: nanodbc/nanodbc.cpp:983: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Any ideas on what I can change to make a successful connection?
Thanks.
Related
I am trying to work on R notebook on ML Studio. Using regular python is easy and works as expected but with R i am facing challenges.
While trying to connect to MS SQL database using odbc() :
library(odbc)
con <- dbConnect(odbc(),
Driver = "SQL Server",
Server = "server",
Database = "db",
UID = "user",
PWD = "password",
Port = 1433)
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found
As suggested in some posts, i have also tried replacing Driver = "SQL Server", with Driver = "ODBC Driver 11 for SQL Server". But i see similar error
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 11 for SQL Server' : file not found
Traceback:
Please suggest a work around.
We can assign the Driver as the version of the SQL server and get the password using the API call.
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "ODBC Driver 13 for SQL Server",
Server = "your server IP address",
Database = "Database name",
UID = "User ID",
PWD = rstudioapi::askForPassword("password"),
Port = port_number_under_user)
In some cases, Driver = "SQL Server” will also work fine. If not functioning. Use the above code block.
I am trying to connect to a MySQL database from within R using odbc. If I write the connection information it works well, however, if I put the same information in a odbc.ini file, I get an error.
Here is the code that works
library(DBI)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "MySQL ODBC 8.0 ANSI Driver",
Server = "localhost",
UID = "myname",
PWD = "mypassword",
Database = "vgr",
encoding = "latin1",
Port = 3306)
And here the code that doesn't work
con <- DBI::dbConnect(odbc::odbc(), 'MySQL')
The error is (it looks like dbConnect doesn't find the information):
Error: nanodbc/nanodbc.cpp:983: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
This is in my odbc.ini either in the working directory or where Windows saves it ODBC.ini file.
[MySQL]
Driver = MySQL ODBC 8.0 ANSI Driver
Server = localhost
UID = myname
PWD = mypassword
Database = vgr
encoding = latin1
Port = 3306
Any help would be appreciated.
Cheers
Renger
I'm trying to connect to a mongoDB database using library(odbc) in R. First I installed the driver from here and then I have used the following method:
con <- dbConnect(odbc::odbc(),
Driver = "MongoDB ODBC 1.3.0 Unicode Driver",
Server = "xxxxx",
AuthMechanism = "SCRAM-SHA-1",
Port = 27017,
Database = "test",
UID = "utest",
PWD = "ptest"
)
However the following error will happen:
Error: nanodbc/nanodbc.cpp:983: 08S01: [MySQL][ODBC 1.3(w) Driver]Lost
connection to MySQL server at 'waiting for initial communication
packet', system error: 10060
I would appreciate any help.Thanks
I have a problem to connect to my external sql server database on R. I am working on macOS. I tried to do everything as in tutorial: LINK
My code:
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(), Driver = "SQL Server", Server = "server", Database = "DataBaseName", UID = "Login", PWD = "password", Port = 1433)
but I still get this same error:
ERROR: nanodbc/nanodbc.cpp:950: 01000: [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found
Does anyone know how to solve this problem? I will be very grateful!
I'm trying to use
odbcDriverConnect("driver={SQL
Server};server=IP;database=DBNAME;uid=username;pwd=password")
to connecting sql server database from shiny R,
but its result is -1.
I run the same code in R studio and get results normally, what's the problem?
For testing more I tried this one:
con <- dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "IP",
Database = "dbname",
UID = "username",
PWD ="password",
Port = Port)
But again it runs in R studio but not in shiny and gets this error:
nanodbc/nanodbc.cpp:950: IM002: [unixODBC][Driver Manager]Data source name
not found, and no default driver specified