繁体   English   中英

无法将 ElephantSQL 数据库连接到 django

[英]Cannot connect ElephantSQL database to django

我正在尝试将大象 sql 服务连接到 django。 我在 settings.py 中配置了数据库设置。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'test_db1',
        'USER': 'xxxxx',
        'PASSWORD': 'xxxxxxxxxxxxxxxxxxxx',
        'HOST': 'arjuna.db.elephantsql.com',
        'PORT': ''
    }
}

但是当我进行迁移时它会出错。

RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': connection to server at "heffalump.db.elephantsql.com" (50.18.63.64), port 5432 failed: FATAL:  no pg_hba.conf entry for host "123.231.123.61", user "hlcreaar", database "test_db2", SSL on
connection to server at "heffalump.db.elephantsql.com" (50.18.63.64), port 5432 failed: FATAL:  no pg_hba.conf entry for host "123.231.123.61", user "hlcreaar", database "test_db2", SSL off

我尝试添加端口号 5432,但它仍然不起作用。 有人可以帮我解决这个错误吗?

我目前按如下方式运行我的连接,

DATABASES = {

     'default': {

         'ENGINE': 'django.db.backends.postgresql_psycopg2',

         'NAME': 'test_db1',

         'USER': 'test_db1',

         'PASSWORD': '************************',

         'HOST': 'arjuna.db.elephantsql.com',

         'PORT': '5432',

     }
 }

注意我正在使用 psycopg2。 名称和用户相同。

错误显示此主机“heffalump.db.elephantsql.com”您是否在某个时候更改了数据库? 如果你这样做了,这可能就是问题所在,你可能需要对迁移做一些工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM