sqliteCopyDatabase: Copy a SQLite database

Description Usage Arguments Author(s) References Examples

View source: R/copy.R

Description

Copies a database connection to a file or to another database connection. It can be used to save an in-memory database (created using dbname = ":memory:" or dbname = "file::memory:") to a file or to create an in-memory database a copy of another database.

Usage

1

Arguments

from

A SQLiteConnection object. The main database in from will be copied to to.

to

A SQLiteConnection object pointing to an empty database.

Author(s)

Seth Falcon

References

https://www.sqlite.org/backup.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(DBI)
# Copy the built in databaseDb() to an in-memory database
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbListTables(con)

db <- RSQLite::datasetsDb()
RSQLite::sqliteCopyDatabase(db, con)
dbDisconnect(db)
dbListTables(con)

dbDisconnect(con)

Example output

character(0)
 [1] "BOD"              "CO2"              "ChickWeight"      "DNase"           
 [5] "Formaldehyde"     "Indometh"         "InsectSprays"     "LifeCycleSavings"
 [9] "Loblolly"         "Orange"           "OrchardSprays"    "PlantGrowth"     
[13] "Puromycin"        "Theoph"           "ToothGrowth"      "USArrests"       
[17] "USJudgeRatings"   "airquality"       "anscombe"         "attenu"          
[21] "attitude"         "cars"             "chickwts"         "esoph"           
[25] "faithful"         "freeny"           "infert"           "iris"            
[29] "longley"          "morley"           "mtcars"           "npk"             
[33] "pressure"         "quakes"           "randu"            "rock"            
[37] "sleep"            "stackloss"        "swiss"            "trees"           
[41] "warpbreaks"       "women"           

RSQLite documentation built on Aug. 21, 2021, 5:07 p.m.