copy_to.src_sql {dplyr} | R Documentation

## Copy a local data frame to a sqlite src.

### Description

This standard method works for all sql sources.

### Usage

    ## S3 method for class 'src_sql'
    copy_to(dest, df, name = deparse(substitute(df)),
      types = NULL, temporary = TRUE, indexes = NULL, analyze = TRUE, ...)

### Arguments

`dest` | remote data source
`df` | local data frame
`name` | name for new remote table.
`types` | a character vector giving variable types to use for the columns. See http://www.sqlite.org/datatype3.html for available types.
`temporary` | if `TRUE`, will create a temporary table that is local to this connection and will be automatically deleted when the connection expires
`indexes` | a list of character vectors. Each element of the list will create a new index.
`analyze` | if `TRUE` (the default), will automatically ANALYZE the new table so that the query optimiser has useful information.
`...` | other parameters passed to methods.

### Value

a sqlite `tbl` object

### Examples

    if (requireNamespace("RSQLite")) {
    db <- src_sqlite(tempfile(), create = TRUE)

    iris2 <- copy_to(db, iris)
    mtcars$model <- rownames(mtcars)
    mtcars2 <- copy_to(db, mtcars, indexes = list("model"))

    explain(filter(mtcars2, model == "Hornet 4 Drive"))

    # Note that tables are temporary by default, so they're not
    # visible from other connections to the same database.
    src_tbls(db)
    db2 <- src_sqlite(db$path)
    src_tbls(db2)
    }

[Package dplyr version 0.4.3 Index]