【问题标题】:Postgres FATAL database does not exist DjangoPostgres FATAL 数据库不存在 Django
【发布时间】:2014-04-09 23:39:09
【问题描述】:

我看到很多这样的问题是针对 Ruby 而不是针对 DJango 的。我们有一个 postgres 数据库,并使用我们的 postgres 用户创建了一个表名 Adam。当你psql -l 时,表格就会出现。但是,在尝试运行迁移时,我们会遇到错误。

FATAL:  database "/var/lib/pgsql/9.3/data/Adam" does not exist

psql -l 显示:

Name       |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------------+----------+----------+-------------+-------------+-----------------------
 Adam      | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

Django settings.py 看起来像..

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.path.join('/var/lib/pgsql/9.3/data/', 'Adam'),
        'USER': 'postgres',
        'PASSWORD': 'correctlyTypePassword'
    }
}

任何想法为什么它认为这不存在?

【问题讨论】:

    标签: python django postgresql


    【解决方案1】:

    您的数据库设置错误。键“名称”应指数据库名称而不是其路径。试试这个:

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'Adam',
        'USER': 'postgres',
        'PASSWORD': 'correctlyTypePassword'
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-25
      • 2016-03-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-29
      • 2020-09-04
      相关资源
      最近更新 更多