为INSTALLED_APPS生成表失败

时间:2012-06-10 15:26:25

标签: python django django-models django-admin django-views

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "D:\PythonPack\lib\site-packages\django\core\management\__init__.py", lin
e 443, in execute_from_command_line
    utility.execute()
  File "D:\PythonPack\lib\site-packages\django\core\management\__init__.py", lin
e 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\PythonPack\lib\site-packages\django\core\management\base.py", line 19
6, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "D:\PythonPack\lib\site-packages\django\core\management\base.py", line 23
2, in execute
    output = self.handle(*args, **options)
  File "D:\PythonPack\lib\site-packages\django\core\management\base.py", line 37
1, in handle
    return self.handle_noargs(**options)
  File "D:\PythonPack\lib\site-packages\django\core\management\commands\syncdb.p
y", line 57, in handle_noargs
    cursor = connection.cursor()
  File "D:\PythonPack\lib\site-packages\django\db\backends\__init__.py", line 30
6, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "D:\PythonPack\lib\site-packages\django\db\backends\sqlite3\base.py", lin
e 281, in _cursor
    self._sqlite_create_connection()
  File "D:\PythonPack\lib\site-packages\django\db\backends\sqlite3\base.py", lin
e 271, in _sqlite_create_connection
    self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file

我在尝试

后遇到了这些错误
python manage.py syncbd

在本教程中 https://docs.djangoproject.com/en/dev/intro/tutorial01/

用Django(Dian-go或Jan-go?)启动第一个Web应用程序。 有人可以帮我解决导致这些错误消息的原因吗?

更新

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'D:\Python\mysite\sqlitedb',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

这是数据库设置

1 个答案:

答案 0 :(得分:0)

Windows用户应该使用/而不是\来设置settings.py中的文件路径 使用D:/Python/mysite/sqlitedb代替D:\Python\mysite\sqlitedb