Unable to connect to database using RSQLite

Viewed 7348

So I'm trying to access my DB file without success. Here is my script:

library(DBI)

library(sqldf)

drv <- dbDriver("SQLite")

con <- dbConnect(drv, dbname = "database.sqlite")

and here is the error:

drv <- dbDriver("SQLite")

con <- dbConnect(drv, dbname = "database.sqlite")

Error in rsqlite_connect(dbname, loadable.extensions, flags, vfs) : Could not connect to database: unable to open database file

I've checked, of course, and made sure that I've installed the packages correctly and that my working directory is set.

4 Answers

I also had this issue. I double checked the path and spotted the mistake there. Once I provided the correct path, the connection worked.

Thanks for this post. It draw my attention to double check if the path was correct.

I ran into a similar problem and the solution was to use forward slashes when issuing dbConnect. I had a working directory defined as "C:\ ..." which worked fine in the rest of my code but not when I tried to open the file with dbConnect.

Related