How to establish a connection to a remote Redash database using R

0 votes

I want to use R, and specifically the {DBI} package, to access a remote Redash DB. Typically, DBI requires to establish a connection first. Such as:

# taken from: https://r4ds.hadley.nz/databases.html#connecting-to-a-database
con <- DBI::dbConnect(
  RMariaDB::MariaDB(), 
  username = "foo"
)
## or
con <- DBI::dbConnect(
  RPostgres::Postgres(), 
  hostname = "databases.mycompany.com", 
  port = 1234
)

Similarly, there's a package that supports accessing AWS:

library(DBI)
library(noctua)

con <- dbConnect(noctua::athena(),
                aws_access_key_id='YOUR_ACCESS_KEY_ID',
                aws_secret_access_key='YOUR_SECRET_ACCESS_KEY',
                s3_staging_dir='s3://path/to/query/bucket/',
                region_name='eu-west-1')

My question: is there a similar (or any!) way to access a Redash DB from R?

Feb 16, 2023 in Data Science by sarit
• 1,830 points
661 views

1 answer to this question.

0 votes

To connect to a Redash database using R and the {DBI} package:

  1. Determine the database type (e.g. PostgreSQL)
  2. Install the R package for that type (e.g. RPostgreSQL)
  3. Load the {DBI} and the driver package
  4. Use dbConnect() to establish a connection using the appropriate parameters
  5. Query the database with {DBI} functions and close the connection with dbDisconnect().

Unlock the power of data and embark on a journey towards becoming a skilled data scientist. Join our comprehensive Data Science Training program today!

answered Feb 17, 2023 by anonymous

Related Questions In Data Science

0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
1,044 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
465 views
0 votes
0 answers

In R, how to get an object's name after it is sent to a function?

I'm trying to find the opposite of ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
300 views
0 votes
0 answers

How to manually find the minors of a matrix in R programming?

I have to write a function that ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
443 views
0 votes
0 answers

How to read a csv-file from an url in R?

I'm not very experienced with R, so ...READ MORE

Jul 22, 2022 in Data Science by avinash
• 1,840 points
642 views
0 votes
1 answer

How To Create Vector of Vector In R

Create a list: List() on x returns x[[1]] ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
478 views
0 votes
1 answer

How to connect to mysql database from rstudio?

Connect to the database as below. install.packages("odbc") db = ...READ MORE

answered Oct 7, 2019 in Data Analytics by anonymous
• 33,030 points
3,657 views
0 votes
1 answer

Error with running SQL Query:

Use below code. ofc <- dbGetQuery(db,'select * from ...READ MORE

answered Oct 1, 2019 in Data Analytics by anonymous
• 33,030 points
1,067 views
0 votes
1 answer

Show SQL equivalent code of dplyr code in R

show_query() translated dplyr code into sql equivalent ...READ MORE

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
2,177 views
+1 vote
1 answer

How to setup any database connection in R?

Here is how you set up a ...READ MORE

answered Oct 14, 2019 in Data Analytics by anonymous
• 33,030 points
1,914 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP