tidyverse / dplyr

dplyr: A grammar of data manipulation
https://dplyr.tidyverse.org/
Other
4.75k stars 2.12k forks source link

Is there dplyr support for any jdbc compliant database? Ask #2530

Closed avinashmaheshjoshi closed 7 years ago

avinashmaheshjoshi commented 7 years ago

I was trying to use dplyr in an environment where we have a set of JDBC compliant databases and I need to support all of them. Instead of adding data sources for each of them, it made sense to see if something is available for using JDBC drivers to make database connections and run queries.

Below are the things I have tried,

  1. I tried to get dplyrJDBC package to work - https://github.com/jimhester/dplyrJDBC. I kept getting the error "dbi_connect" not found.

  2. Followed Hadley's comment thread on this issue - https://github.com/hadley/dplyr/issues/329 Where he explains how to add a new data source to dplyr.

If I understood it correctly, the dbi_connect method needs to be implemented for whichever new datasource is to be added. So either the dplyrJDBC package is missing something or something incorrect in the way I am installing it or has the function been updated?

If the dplyrJDBC option doesn't work out, is there a way for me to connect to any JDBC compliant database and use dplyr or just adding each of the data source my only option?

hadley commented 7 years ago

In the dev version, you can just use src_dbi().

mruepp commented 7 years ago

I tried to use src_dbi() by enabling the dev package in my R Script:

devtools::install_github("tidyverse/dplyr") library(dplyr)

' @importFrom(dplyr, src_dbi)

drv <- JDBC("com.my.client.jdbc.Driver","/home/rstudio/projects/jdbc/jdbc.jar") conn <- dbConnect(drv, "jdbc:client://url:5432/rstudio")

Wether scr_dbi(conn) nor crateDb <- dplyr:::src_dbi(conn)

is working: Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'src_dbi' not found

So how can I use JDBC Driver with dplyr?

Thx

hadley commented 7 years ago

@mruepp please ask questions on the manipulatr mailing list, not in GitHub issues.