Learn R Programming

pool (version 0.1.4.3)

dplyr-db-methods: DBIConnection methods from dplyr and dbplyr

Description

Pool object wrappers around DBIConnection methods, whose generics are defined either in dplyr or in dbplyr. For the original documentation, see dplyr's reference page and dbplyr's reference page.

Usage

# S3 method for Pool
copy_to(dest, df, name = deparse(substitute(df)),
  overwrite = FALSE, temporary = TRUE, ...)

# S3 method for Pool tbl(src, from, ...)

# S3 method for Pool db_analyze(con, table, ...)

# S3 method for Pool db_begin(con, ...)

# S3 method for Pool db_commit(con, ...)

# S3 method for Pool db_create_index(con, table, columns, name = NULL, unique = FALSE, ...)

# S3 method for Pool db_create_indexes(con, table, indexes = NULL, unique = FALSE, ...)

# S3 method for Pool db_create_table(con, table, types, temporary = FALSE, ...)

# S3 method for Pool db_data_type(con, fields)

# S3 method for Pool db_desc(x)

# S3 method for Pool db_drop_table(con, table, force = FALSE, ...)

# S3 method for Pool db_explain(con, sql, ...)

# S3 method for Pool db_has_table(con, table)

# S3 method for Pool db_insert_into(con, table, values, ...)

# S3 method for Pool db_list_tables(con)

# S3 method for Pool db_query_fields(con, sql, ...)

# S3 method for Pool db_query_rows(con, sql, ...)

# S3 method for Pool db_rollback(con, ...)

# S3 method for Pool db_save_query(con, sql, name, temporary = TRUE, ...)

# S3 method for Pool db_write_table(con, table, types, values, temporary = FALSE, ...)

# S3 method for Pool sql_escape_ident(con, x)

# S3 method for Pool sql_escape_string(con, x)

# S3 method for Pool sql_join(con, x, y, vars, type = "inner", by = NULL, ...)

# S3 method for Pool sql_select(con, select, from, where = NULL, group_by = NULL, having = NULL, order_by = NULL, limit = NULL, distinct = FALSE, ...)

# S3 method for Pool sql_semi_join(con, x, y, anti = FALSE, by = NULL, ...)

# S3 method for Pool sql_subquery(con, from, name = random_table_name(), ...)

# S3 method for Pool sql_translate_env(con)

# S3 method for Pool db_collect(con, sql, n = -1, warn_incomplete = TRUE, ...)

# S3 method for Pool db_compute(con, table, sql, temporary = TRUE, unique_indexes = list(), indexes = list(), ...)

# S3 method for Pool db_copy_to(con, table, values, overwrite = FALSE, types = NULL, temporary = TRUE, unique_indexes = NULL, indexes = NULL, analyze = TRUE, ...)

# S3 method for Pool db_sql_render(con, sql, ...)

# S3 method for Pool sql_escape_logical(con, x)

Arguments

dest, df, name, overwrite, temporary, ..., src, from, con, table, columns, unique, indexes, types, fields, x, force, sql, values, y, vars, type, by, select, where, group_by, having, order_by, limit, distinct, anti, n, warn_incomplete, unique_indexes, anal

See original documentation.

Examples

Run this code
# NOT RUN {
if (requireNamespace("RSQLite", quietly = TRUE)) {
  library(dplyr)

  pool <- dbPool(RSQLite::SQLite(), dbname = ":memory:")

  # describe the type of the pool/its connections
  db_desc(pool)

  # use dplyr syntax to copy a table into the database
  copy_to(pool, mtcars, "mtcars", temporary = FALSE)

  # list the current tables in the database
  db_list_tables(pool)

  # extract a table from the database
  mtcars_db <- tbl(pool, "mtcars")

  # select only 3 columns
  mtcars_db_thin <- select(mtcars_db, mpg, cyl, disp)

  # get the names of the columns in the databases's table
  db_query_fields(pool, "mtcars")

  # get the number of rows in the databases's table
  db_query_rows(pool, "mtcars")

  # drop the "mtcars" table from the database
  db_drop_table(pool, "mtcars")

  # list the current tables in the database
  db_list_tables(pool)

  poolClose(pool)

} else {
  message("Please install the 'RSQLite' package to run this example")
}
# }

Run the code above in your browser using DataLab