插入过程中出现 SQLite 错误“尝试写入只读数据库"?

SQLite error #39;attempt to write a readonly database#39; during insert?(插入过程中出现 SQLite 错误“尝试写入只读数据库?)
本文介绍了插入过程中出现 SQLite 错误“尝试写入只读数据库"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于网站的 SQLite 数据库.问题是当我尝试 INSERT INTO 它时,我得到一个 PDOException

I have a SQLite database that I am using for a website. The problem is that when I try to INSERT INTO it, I get a PDOException

SQLSTATE[HY000]: General error: 8 attempt to write a readonly database

我通过 SSH 连接到服务器并检查权限,并且数据库具有权限

I SSH'd into the server and checked permissions, and the database has the permissions

-rw-rw-r--

我不太熟悉 *nix 权限,但我很确定这意味着

I'm not that familiar with *nix permissions, but I'm pretty sure this means

  • 不是目录
  • 所有者具有读/写权限(根据 ls -l,就是我)
  • 组具有读/写权限
  • 其他人只有读取权限

我还查看了所有我知道使用 sqlite3 程序的地方,但没有发现任何相关内容.

I also looked everywhere I knew to using the sqlite3 program, and found nothing relevant.

因为我不知道 PDO 试图以什么权限打开数据库,所以我知道

Because I didn't know with what permissions PDO is trying to open the database, I did

chmod o+w supplies.db

现在,我得到另一个PDOException:

SQLSTATE[HY000]: General error: 14 unable to open database file

但它仅在我尝试在数据库打开后执行INSERT查询时发生.

But it ONLY occurs when I try to execute an INSERT query after the database is open.

对正在发生的事情有什么想法吗?

推荐答案

事实证明,问题在于 PDO SQLite 驱动程序要求如果您要执行写操作(INSERTUPDATEDELETEDROP等),那么数据库所在的文件夹必须有写权限,以及实际的数据库文件.

The problem, as it turns out, is that the PDO SQLite driver requires that if you are going to do a write operation (INSERT,UPDATE,DELETE,DROP, etc), then the folder the database resides in must have write permissions, as well as the actual database file.

我在位于PDO SQLite 驱动程序手册页.

I found this information in a comment at the very bottom of the PDO SQLite driver manual page.

这篇关于插入过程中出现 SQLite 错误“尝试写入只读数据库"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

FastAPI + Tortoise ORM + FastAPI Users (Python) - Relationship - Many To Many(FastAPI+Tortoise ORM+FastAPI用户(Python)-关系-多对多)
Window functions not working in pd.read_sql; Its shows error(窗口函数在pd.read_sql中不起作用;它显示错误)
(Closed) Leaflet.js: How I can Do Editing Geometry On Specific Object I Select Only?((已关闭)Leaflet.js:如何仅在我选择的特定对象上编辑几何图形?)
in sqlite update trigger with multiple if/Case Conditions(在具有多个IF/CASE条件的SQLite UPDATE触发器中)
Android: Why is Room so slow?(Android:为什么Room这么慢?)
Remote Procedure call failed with sql server 2008 R2(使用 sql server 2008 R2 的远程过程调用失败)