Skip to content

RSQLite::dbWriteTable can't handle grouped_df #2276

@joranE

Description

@joranE

I'm filing this here, since it seems specific to the case of a tbl_df with the S3 class signature of:

[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"

and it seems like the issue was raised in RSQLite, but eventually solved for the case of just

[1] "tbl_df"     "tbl"        "data.frame"

in tibble. Let me know if you'd prefer it filed somewhere else...

Here's the setup:

library(DBI)
library(RSQLite)
library(dplyr)
mtcars <- group_by(.data = mtcars,cyl)

d> class(mtcars)
[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"

mydb <- dbConnect(RSQLite::SQLite(), ":memory:")

d> dbWriteTable(conn = mydb,name = "mtcars",value = mtcars)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘dbWriteTable’ for signature ‘"SQLiteConnection", "character", "grouped_df"’

Based on what I read in previous issues, I guess a suitable setOldClass() directive needs to be issued somewhere in dplyr for grouped_df's.

Session Info:

d> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X El Capitan 10.11.5

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DBI_0.5-12      dplyr_0.5.0     RSQLite_1.1     devtools_1.12.0

loaded via a namespace (and not attached):
 [1] lazyeval_0.2.0 magrittr_1.0.1 R6_2.1.2       assertthat_0.1 tools_3.3.2    withr_1.0.2    tibble_1.2    
 [8] Rcpp_0.12.7    memoise_1.0.0  digest_0.6.9  

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions