【问题标题】:Please supply the ENGINE value Django database configuration请提供 ENGINE 值 Django 数据库配置
【发布时间】:2012-07-12 12:49:17
【问题描述】:

伙计们,我很困惑,我已经安装了 Django,并且运行服务器正常,但是当尝试配置数据库并运行 db sync 命令时,它崩溃返回我的 ENGINE 参数不正常,但设置文件是好的。按照设置文件:

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mysite',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # 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.
    }
}

还有错误:

 Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 371, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
    cursor = connection.cursor()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/dummy/base.py", line 15, in complain
    raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

提前致谢!

【问题讨论】:

  • 尝试在syncdb之后添加--settings=myapp.settings...这有时会有所帮助..
  • 我已经执行了这个:python manage.py --settings=mysite.settings syncdb 我得到了这个:未知命令:'--settings=mysite.settings' :(我正在使用 Django 1.4
  • python manage.py syncdb --settings=mysite.settings 顺序很重要:)
  • 同样的问题,我将 ENGINE 设置为 django.db.backends.sqlite3 但我仍然收到 ENGINE not set 错误

标签: python database django settings


【解决方案1】:

我知道这篇文章很古老,但我刚刚遇到了同样的错误。对我来说,问题在于 USER 和 PASSWORD 不匹配。我最终只是进入数据库并手动重置密码,然后将新密码放入脚本中。这解决了我的问题。

【讨论】:

  • 我最近遇到了这个问题,这是由于两个数据库字典之间缺少逗号。 ImproperlyConfigured 暗示了 DATABASES 字典周围的许多不同变量:内容和形式。
【解决方案2】:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysite',
        'USER': 'mysite',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306',
     }
}

使用上述设置请检查mysql用户的授予权限并指定主机和端口。

【讨论】:

    猜你喜欢
    • 2013-01-08
    • 2017-10-20
    • 2021-10-21
    • 2013-11-28
    • 2017-04-21
    • 1970-01-01
    • 2014-11-22
    • 2012-08-03
    • 2012-04-08
    相关资源
    最近更新 更多