I recently updated R, RSQLite and sqldf (versions below).
Usually:
sqldf('create table foo as select * from bar', db = 'test.db')
should create a table named 'foo' in the attached sqlite database using the data frame 'bar' if it exists to load a new table.
Instead, I get a "no such table" error, and when I look at the database, the tables "foo" and "bar" are created.
Playable example:
library(RSQLite) library(sqldf) mydb = 'test.db' ## remove file if it exists system(paste('rm', mydb)) ## open connection ##con <- dbConnect(SQLite(), dbname=mydb) system(paste('ls -l', mydb)) sqldf( paste0( 'attach "', mydb, '" as new' ) ) system(paste('ls -l', mydb)) class(mtcars) sqldf( 'create table mycars as select * from mtcars', dbname = mydb ) sqldf('select * from sqlite_master', dbname = mydb) sqldf('select * from main.mycars limit 1', dbname = mydb) sqldf('select * from main.mtcars limit 1', dbname = mydb) sessionInfo()
which creates two tables and throws an error (to add insult to injury):
> library(RSQLite) > library(sqldf) Loading required package: gsubfn Loading required package: proto > mydb = 'test.db' >
source share