rsqlitedataframe

How to use Rsqlite to save and load data in SQLite?


I have a data frame in CSV format and imported it into SQLite:

db <- dbConnect(SQLite(), dbname="myDB.sqlite")
dbWriteTable(conn = db, name = "myDB", dataframe, overwrite=T,
         row.names=FALSE)

Now there is a myDB.sqlite file in my directory but with zero bytes. How can I save the dataframe in the SQLite database so that I don't need to write the table every time?


Solution

  • It should be written in your db. Like i said before, your code works for me it's just that the R-Studio File Viewer doesn't automatically Refresh when some of the files have been written to.

    Just to be sure that data was written to your db try running this dbGetQuery(conn=db, "SELECT * FROM myDB). That should return your data frame.