## Create an in memory database
db <- dbConnect(SQLite(), dbname = ":memory:")
df <- data.frame(letters=letters[1:4], numbers=1:4)
ok <- dbWriteTable(db, "table1", df, row.names = FALSE)
stopifnot(ok)
## Copy the contents of the in memory database to
## the specified file
backupDbFile <- tempfile()
ok <- sqliteCopyDatabase(db, backupDbFile)
stopifnot(ok)
## cleanup
dbDisconnect(db)
unlink(backupDbFile)
Run the code above in your browser using DataLab