且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

sqlite3.OperationalError:无法打开数据库文件

更新时间:2023-11-25 15:15:28

a href =https://code.djangoproject.com/wiki/NewbieMistakes#DjangosaysUnabletoOpenDatabaseFilewhenusingSQLite3 =noreferrer> Django NewbieMistakes

Django NewbieMistakes


PROBLEM您正在使用SQLite3,您的DATABASE_NAME设置为
数据库文件的完整路径,数据库文件可由Apache写入
,但您仍会收到以上错误。

PROBLEM You're using SQLite3, your DATABASE_NAME is set to the database file's full path, the database file is writeable by Apache, but you still get the above error.

解决方案确保Apache也可以写入
数据库的父目录。 SQLite需要能够写入此目录。

SOLUTION Make sure Apache can also write to the parent directory of the database. SQLite needs to be able to write to this directory.

确保数据库文件的完整路径的每个文件夹不会以数字启动
,例如。 / www / 4myweb / db(在Windows 2000上观察)。

Make sure each folder of your database file's full path does not start with number, eg. /www/4myweb/db (observed on Windows 2000).

如果DATABASE_NAME设置为
'/ Users / yourname / Sites / mydjangoproject / db / db',确保你
先创建了'db'目录。

If DATABASE_NAME is set to something like '/Users/yourname/Sites/mydjangoproject/db/db', make sure you've created the 'db' directory first.

确保你的/ tmp目录是世界可写的作为
其他的东西在你的系统上也不行)。 ls / tmp -ald应该
产生drwxrwxrwt ....

Make sure your /tmp directory is world-writable (an unlikely cause as other thing on your system will also not work). ls /tmp -ald should produce drwxrwxrwt ....

确保settings.py中指定的数据库的路径是完整的
路径。

Make sure the path to the database specified in settings.py is a full path.

还要确保文件存在于您期望的位置。

Also make sure the file is present where you expect it to be.