无法使用RSQLite连接到数据库(Unable to connect to database using RSQLite)

编程入门 行业动态 更新时间:2024-10-26 01:17:16
无法使用RSQLite连接到数据库(Unable to connect to database using RSQLite)

所以我试图访问我的数据库文件没有成功,这是我的脚本:

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.

更多推荐

本文发布于:2023-08-06 10:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1446711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   数据库   RSQLite   database   connect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!