所以我试图访问我的数据库文件没有成功,这是我的脚本:
library(DBI) library(sqldf) drv <- dbDriver("SQLite") con <- dbConnect(drv, dbname = "database.sqlite")这是错误:
drv < - dbDriver(“SQLite”)
con < - dbConnect(drv,dbname =“database.sqlite”)
rsqlite_connect中的错误(dbname,loadable.extensions,flags,vfs):无法连接到数据库:无法打开数据库文件
我已经检查了当然并确保我已经正确安装了包装并且我的工作目录已经设置好了。
so im 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 packeges correctly and that my working directory is set.
最满意答案
我可以通过两种方式复制此错误:
该文件存在,但您无权打开它这可能是因为操作系统权限。 检查您的权限。
该文件不存在,您无权创建它。如果要求SQLite打开不存在的数据库文件,它会尝试创建它。 如果失败,则会收到该错误消息。 如果DB文件的路径(在本例中是当前工作目录)不允许您创建文件,则会失败。 检查您的权限。
请注意,如果文件确实存在但已损坏,我会收到不同的错误:
> con <- dbConnect(drv, dbname = "database.sqlite") Error in rsqlite_send_query(conn@ptr, statement) : file is encrypted or is not a database >所以这可能不是你的问题。
I have solved my problem, and its a bit embarrassing:
I've saved my file on my desktop. since my OS in installed in my native language (Hebrew) the file path had one Hebrew word in it, and while that doesn't pose a problem with reading tables into R, it does pose a problem to the SQL connection.
solving it was easy - I've saved the file in a new folder on my hard drive (c:\database), set as working dir, and everything worked fine.
更多推荐
发布评论