• <legend id='L7lVL'><style id='L7lVL'><dir id='L7lVL'><q id='L7lVL'></q></dir></style></legend>
  • <tfoot id='L7lVL'></tfoot>

          <bdo id='L7lVL'></bdo><ul id='L7lVL'></ul>
      1. <i id='L7lVL'><tr id='L7lVL'><dt id='L7lVL'><q id='L7lVL'><span id='L7lVL'><b id='L7lVL'><form id='L7lVL'><ins id='L7lVL'></ins><ul id='L7lVL'></ul><sub id='L7lVL'></sub></form><legend id='L7lVL'></legend><bdo id='L7lVL'><pre id='L7lVL'><center id='L7lVL'></center></pre></bdo></b><th id='L7lVL'></th></span></q></dt></tr></i><div id='L7lVL'><tfoot id='L7lVL'></tfoot><dl id='L7lVL'><fieldset id='L7lVL'></fieldset></dl></div>

        <small id='L7lVL'></small><noframes id='L7lVL'>

        Django“无法打开数据库文件"

        Django is quot;unable to open database filequot;(Django“无法打开数据库文件)

          <bdo id='nD2EZ'></bdo><ul id='nD2EZ'></ul>

          <small id='nD2EZ'></small><noframes id='nD2EZ'>

              <tfoot id='nD2EZ'></tfoot>

              • <i id='nD2EZ'><tr id='nD2EZ'><dt id='nD2EZ'><q id='nD2EZ'><span id='nD2EZ'><b id='nD2EZ'><form id='nD2EZ'><ins id='nD2EZ'></ins><ul id='nD2EZ'></ul><sub id='nD2EZ'></sub></form><legend id='nD2EZ'></legend><bdo id='nD2EZ'><pre id='nD2EZ'><center id='nD2EZ'></center></pre></bdo></b><th id='nD2EZ'></th></span></q></dt></tr></i><div id='nD2EZ'><tfoot id='nD2EZ'></tfoot><dl id='nD2EZ'><fieldset id='nD2EZ'></fieldset></dl></div>
                    <tbody id='nD2EZ'></tbody>
                  <legend id='nD2EZ'><style id='nD2EZ'><dir id='nD2EZ'><q id='nD2EZ'></q></dir></style></legend>
                  本文介绍了Django“无法打开数据库文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  运行python manage.py syncdb"后,我收到一条错误消息,提示无法打开数据库文件".

                  这是我的 settings.py 中的重要部分:

                  DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2'、'postgresql'、'mysql'、'sqlite3' 或 'oracle'.DATABASE_NAME = 'apps.db' # 如果使用 sqlite3,则为数据库文件的路径.DATABASE_USER = '' # 不用于 sqlite3.DATABASE_PASSWORD = '' # 不用于 sqlite3.DATABASE_HOST = '' # 为本地主机设置为空字符串.不与 sqlite3 一起使用.DATABASE_PORT = '' # 默认设置为空字符串.不与 sqlite3 一起使用.

                  这里是apps.db"的权限:

                  -rw-r--r-- 1 root root 33792 19. Jul 10:51 apps.db

                  我的 django 服务器是从 apache 调用的...我不知道这是否与权限有关,但是将 apps.db 的所有者更改为www-data"也不起作用

                  为了确保 www-data 可以访问所有这些,我做了以下事情:

                  做了以下事情:

                  chown -R www-data 应用rm 应用程序.dbsu www-datapython manage.py syncdb

                  但是还是不行:(

                  解决方案

                  我通过将 DATABASE_NAME 更改为绝对路径解决了该错误:/var/www/apps/apps.db.>

                  在 Windows 机器上,反斜杠应该像这样转义:C:\path\to\database\database_name.db.

                  after running "python manage.py syncdb" i gett an error saying "unable to open database file".

                  here is the important part from my settings.py:

                  DATABASE_ENGINE = 'sqlite3'    # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
                  DATABASE_NAME = 'apps.db'      # Or path to database file if using sqlite3.
                  DATABASE_USER = ''             # Not used with sqlite3.
                  DATABASE_PASSWORD = ''         # Not used with sqlite3.
                  DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
                  DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
                  

                  and here are the permissions for "apps.db":

                  -rw-r--r-- 1 root root 33792 19. Jul 10:51 apps.db
                  

                  My django server is called from apache... i don't know if it has to do with the permissions but changing the owner of apps.db to "www-data" did not work either

                  [edit]

                  to ensure www-data can access all of this i did the following:

                  did the following:

                  chown -R www-data apps
                  rm apps.db
                  su www-data
                  python manage.py syncdb
                  

                  but it still does not work :(

                  解决方案

                  I solved the error by changing the DATABASE_NAME to an absolute path: /var/www/apps/apps.db.

                  On a windows machine, backslash should be escaped like: C:\path\to\database\database_name.db.

                  这篇关于Django“无法打开数据库文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQLite loop statements?(SQLite 循环语句?)
                  Can I use parameters for the table name in sqlite3?(我可以在 sqlite3 中使用表名的参数吗?)
                  SQL - Inserting a row and returning primary key(SQL - 插入一行并返回主键)
                  How to get the number of rows of the selected result from sqlite3?(如何从sqlite3中获取所选结果的行数?)
                  Python : How to insert a dictionary to a sqlite database?(Python:如何将字典插入到 sqlite 数据库中?)
                  What are the advantages of VistaDB(VistaDB有什么优势)

                  <tfoot id='Z9Nt8'></tfoot>

                      • <small id='Z9Nt8'></small><noframes id='Z9Nt8'>

                        <i id='Z9Nt8'><tr id='Z9Nt8'><dt id='Z9Nt8'><q id='Z9Nt8'><span id='Z9Nt8'><b id='Z9Nt8'><form id='Z9Nt8'><ins id='Z9Nt8'></ins><ul id='Z9Nt8'></ul><sub id='Z9Nt8'></sub></form><legend id='Z9Nt8'></legend><bdo id='Z9Nt8'><pre id='Z9Nt8'><center id='Z9Nt8'></center></pre></bdo></b><th id='Z9Nt8'></th></span></q></dt></tr></i><div id='Z9Nt8'><tfoot id='Z9Nt8'></tfoot><dl id='Z9Nt8'><fieldset id='Z9Nt8'></fieldset></dl></div>
                        <legend id='Z9Nt8'><style id='Z9Nt8'><dir id='Z9Nt8'><q id='Z9Nt8'></q></dir></style></legend>
                          • <bdo id='Z9Nt8'></bdo><ul id='Z9Nt8'></ul>
                              <tbody id='Z9Nt8'></tbody>