[英]django.db.utils.DatabaseError: file is not a database
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 411, in execute
return Database.Cursor.execute(self, query)
sqlite3.DatabaseError: file is not a database
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inn
er_run
self.check_migrations()
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\core\management\base.py", line 459, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\migrations\loader.py", line 216, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migratio
ns
if self.has_table():
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
tables = self.connection.introspection.table_names(cursor)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\base\introspection.py", line 48, in table_na
mes
return get_names(cursor)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\base\introspection.py", line 43, in get_name
s
return sorted(ti.name for ti in self.get_table_list(cursor)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\sqlite3\introspection.py", line 74, in get_t
able_list
cursor.execute("""
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 98, in execute
return super().execute(sql, params)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_with_wrapper
s
return executor(sql, params, many, context)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "C:\Users\user\PycharmProjects\myweb\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 411, in execute
return Database.Cursor.execute(self, query)
django.db.utils.DatabaseError: file is not a database
首先,錯誤是“DatabaseError: database disk image is malformed”。
db.sqlite3 文件被刪除並重新創建,然后復制並粘貼。 然后就會出現這種錯誤。
我該怎么辦?
這可能是很多問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.