For an undisclosed reason, my Impala does not have a JDBC driver installed. This is making the connection from R to Impala challenging.
I am able to connect (and query) to Impala shell via Putty. E.g.,
impala-shell --ssl -i some_name
Using the Putty connection mechanism/credentials, can this be performed from RStudio and bring in the SELECT results into a dataframe?
This worked in my Oracle BDA cluster.
library(dsreq)
print("Connecting to Impala...")
impaladb <- impalaConnection(pool='general')
dbResultsTempTbl <- dbGetQuery(impaladb, paste0("SELECT * FROM mytable") )
print("results")
print(dbResultsTempTbl)
You can use the ODBC driver to connect to impalaDB
library(ODBC)
drv <- odbc::odbc()
con <- DBI::dbConnect(drv = drv, driver = "Cloudera ODBC Driver for Impala",
host = "your hostname", port = 21050, Schema = "your schema")
Related
I am trying to connect to a firebird DB via ODBC. I have an working ODBC Windows Connection (ODBC Data Sources 32 Bit) and also an established connection via Tableau. I tried using dbConnect but was not able to set the right parameters I guess. I tried
library(odbc)
con <- dbConnect(odbc::odbc(),
drv = "Firebird/InterBase(r) driver",
database = "VARIO",
uid = "xxx",
pwd = "xxx",
host = "192.xxx.xxx.xx",
port = "xxxxx")
in e.g. Excel I can access the database by using the established windows connection. Anyways, sorry for my beginner formulation!
To add here, it seems I am running on 64 bit R Version
> Sys.info()[["machine"]]
[1] "x86-64"
After your comments I tried
con <- dbConnect(odbc::odbc(),
dsn = "VARIO",
database = "192.168.XX.X/56300:VARIO8",
uid = "XXX",
pwd = "XXX",
host = "192.168.XX.X",
port = "56300")
>Error: nanodbc/nanodbc.cpp:983: 01S00: [ODBC Firebird Driver]Unable to connect to data source: library 'C:\Users\XXX\Desktop\fbclient.dll' failed to load [ODBC Firebird Driver]Invalid connection string attribute [ODBC Firebird Driver]Invalid connection string attribute
fbclient.dll is there where its supposed to be
What is more I did not put an driver. Whenever I ad
drv = "Firebird/InterBase(r) driver"
I get: Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dbConnect’ for signature ‘"character"’
Maybe this helps? This is from the Windows ODBC Data Sources and says 32/64 Bit. Don't know if this is imprtant
Any further Ideas?
Checking against the list of odbc-known DB drivers, Firebird doesn't seem to be a known driver.
library(odbc)
odbc::odbcListDrivers()
(src: https://rdrr.io/cran/odbc/man/odbcListDrivers.html)
I guess you would have to install that driver on your machine and then register the Data Source Name (DSN) to make it available to R.
Once that's done, please change the drv in your function call to dsn. drv refers to the odbc::odbc() argument which you've provided above, while dsn should then refer to the installed driver by its registered name (unless I'm mixing up things badly here. I've luckily never had to leave the warm comfort of RPostgreSQL...).
So it would look something like this:
library(odbc)
con <- dbConnect(drv = odbc::odbc(),
dsn = "Firebird", # this should be the DSN you have set
database = "VARIO",
uid = "xxx",
pwd = "xxx",
host = "192.xxx.xxx.xx",
port = "xxxxx")
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 am trying to connect to Teradata database from R terminal using code below,
"> con <- DBI::dbConnect(odbc::odbc(),
+ Driver = "Teradata",
+ Host = "xxxx",
+ DBCName = "xxxx",
+ UID = "xxxx"
+ )"
I have created /etc/odbc.ini and /etc/odbcinst.ini and below are the contents of the same,
odbc.ini:
[ODBC]
InstallDir=/opt/teradata/client/16.20/odbc_64
DataEncryption='ON'
[ngmtdd01]
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
Description=Teradata Dev
DBCName=xxxx.dev.uk.capitalone.com
LoginTimeout=120
odbcinst.ini
[ODBC DRIVERS]
Teradata Database ODBC Driver 16.20=Installed
[Teradata Database ODBC Driver 16.20]
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
APILevel=CORE
ConnectFunctions=YYY
DriverODBCVer=3.51
SQLLevel=1
I expected to get connected to the teradata cli but I am getting below error.
Error: nanodbc/nanodbc.cpp:950: IM002: [DataDirect][ODBC lib] Data source name not found and no default driver specified"
You defined a DSN but your connection string is "DSN-less" (using Driver= not DSN=) and Driver= specifies the wrong driver name; the actual name is Teradata Database ODBC Driver 16.20
Note that Teradata also supplies a Teradata SQL Driver for R package that does not require ODBC.
I am trying to connect R with Microsoft SQL server. I have used Toad for SQL Server 6.8 so far for my queries. However, for some other analysis (which can be easily performed in R) I want to connect database with R.
I have tried R function "dbconnect" with providing server name and database name. See query below:
odbc_con <- dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "xxxxx",
Database = "yyyyy",
Uid = 'US\dhrdesai',
Pwd = rstudioapi::askForPassword("Database password"),
Port = 1433)
However, I got following errors:
Error: nanodbc/nanodbc.cpp:950: IM002: [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
and
Error: unexpected ')' in " Port = 1433)"
Have anyone faced the same or know any other way to connect R with SQL server.
You need to use a double backslash \\ every time you see a \. I just made my connection work yesterday with the following code. Also pehaps you have not installed all the packages that is required.
library(DBI)
library(dbplyr)
library(odbc)
con <- dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "path\\path", # remember \\ if your path has a \
Database = "the_database_name",
user = "your_user_name", # remember \\ if your username has a \
Trusted_Connection = "True")
I am trying to connect my R Studio session to my SQL Server database using library(odbc).
However, the server name is something like "xxx\xxxx", and R is complaining about "an unrecognized escape in character string starting ""xxx\xxxx".
After some googling, I tried Server = ... with two \s then it just complains about "Data source name not found and no default driver specified".
Any insight is appreciated.
Thanks.
library(odbc)
con <- dbConnect(odbc(),
Driver = "SQLServer",
Server = "xx\xxxx",
Database = "xx",
UID = "axx",
PWD = "axx",
Port = 1xxx)
SQL Server Enterprise Edition 64-bit Version 10.50.2500.0;
RStudio Version 1.1.423
I got it resolved, after installing ODBC driver on the PC for SQL Server
#LIBRARY#
library(DBI)
library(shiny)
library(dplyr)
#CONNECTION#
con <- dbConnect(odbc::odbc(), "xxxx")
Thanks