2016-06-15 61 views
-4

堆棧跟蹤:Django的:django.db.utils.OperationalError:無法打開數據庫文件

System check identified no issues (0 silenced). 
Unhandled exception in thread started by <function wrapper at 0x7f58375ac9b0> 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper 
    fn(*args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 116, in inner_run 
    self.check_migrations() 
    File "/usr/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 168, in check_migrations 
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) 
    File "/usr/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 19, in __init__ 
    self.loader = MigrationLoader(self.connection) 
    File "/usr/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__ 
    self.build_graph() 
    File "/usr/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 191, in build_graph 
    self.applied_migrations = recorder.applied_migrations() 
    File "/usr/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 59, in applied_migrations 
    self.ensure_schema() 
    File "/usr/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 49, in ensure_schema 
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()): 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 162, in cursor 
    cursor = self.make_debug_cursor(self._cursor()) 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 135, in _cursor 
    self.ensure_connection() 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 130, in ensure_connection 
    self.connect() 
    File "/usr/lib/python2.7/dist-packages/django/db/utils.py", line 98, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 130, in ensure_connection 
    self.connect() 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 119, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "/usr/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 204, in get_new_connection 
    conn = Database.connect(**conn_params) 
django.db.utils.OperationalError: unable to open database file 

回答

0

你應該在這裏展示您的數據庫設置,並把你的錯誤日誌在一個更好的格式。

我想你正在使用SQLite,對吧?如果是這樣,請檢查您的數據文件路徑: - 它是正確的嗎?應該是全路徑的。 - 您的應用程序是否對其及其父目錄擁有正確的權限(讀/寫) - 確保已創建其父目錄。

相關問題