sorry for the very simple question, but...
How to save a query result build with dbplyr
without load data on memory.
This is what I tried.
library(DBI)
library(odbc)
library(RPostgreSQL)
library(tidyverse)
library(magrittr)
#>
#> Attaching package: 'magrittr'
#> The following object is masked from 'package:purrr':
#>
#> set_names
#> The following object is masked from 'package:tidyr':
#>
#> extract
library(dbplyr)
#>
#> Attaching package: 'dbplyr'
#> The following objects are masked from 'package:dplyr':
#>
#> ident, sql
pgdrv <- dbDriver(drvName = "PostgreSQL")
con <-dbConnect(pgdrv,
dbname="genomes",
host="127.0.0.1", port=5432,
user = 'rotifer')
mtcars %<>%
rownames_to_column()
dbWriteTable(con, "cars", mtcars)
#> [1] TRUE
dbmtcars <- tbl(con, "cars")
dbmtcars %>%
mutate(ts = cyl * carb) -> newtb
newtb %>% show_query()
#> <SQL>
#> SELECT "row.names", "rowname", "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb", "cyl" * "carb" AS "ts"
#> FROM "cars"
newtb %>% db_write_table(con, "newtb")
#> Error in UseMethod("db_write_table"): no applicable method for 'db_write_table' applied to an object of class "c('tbl_PostgreSQLConnection', 'tbl_dbi', 'tbl_sql', 'tbl_lazy', 'tbl')"
Created on 2020-10-09 by the reprex package (v0.3.0)
Thanks in advance