mardi 10 mars 2015

SQLite: Could not connect to database: unable to open database file

I created a database ontime using SQLite Manager for Firefox. Also, I created a table ontime inside this database (see the attached image).


Next I run this code in R:



library(RSQLite)
library(DBI)

sqLiteConnect <- function(database, table) {
con <- dbConnect(RSQLite::SQLite(), dbname = database)
query <- dbSendQuery(con, paste("select count(*), tailnum from ontime group by tailnum ", table, ";", sep=""))
result <- fetch(query, n = -1, encoding="utf-8")
dbClearResult(query)
dbDisconnect(con)
return(result)
}

result <- sqLiteConnect("D:/sqlite/ontime.sqlite","ontime")


The following error message appears:



Error in .local(drv, ...) : Could not connect to database: unable to open database file



HOW TO FIX THIS ISSUE? I don't know why R cannot find the file. It is located in the specified folder.


enter image description here


Update: However, if I execute this line, then there is another error message:



result <- sqLiteConnect("ontime.sqlite","ontime")



Error in sqliteSendQuery(conn, statement) : error in statement: no such table: ontime



The table exists as it is shown in the image below.


Aucun commentaire:

Enregistrer un commentaire