简体   繁体   English

Django psycopg2.OperationalError:fe_sendauth错误,但未连接到PostgreSQL数据库

[英]Django psycopg2.OperationalError: fe_sendauth error but not connecting to postgresql database

I am using the following sqlite connection in my myapp/settings.py file: 我在myapp / settings.py文件中使用以下sqlite连接:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':testdb:',
        #I also tried 'NAME': 'testdb',
    },
}

in my manage.py file I am using: 在我的manage.py文件中,我正在使用:

if __name__ == "__main__":
    os.environ.setdefault("myapp.settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

On running ./manage.py migrate on the command line I get the following error: 在命令行上运行./manage.py迁移时,出现以下错误:

django.db.utils.OperationalError: fe_sendauth: no password supplied

I tried removing psycopg2 and re-ran the migration and get the following error: 我尝试删除psycopg2并重新运行迁移,并得到以下错误:

django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'

I can't work out why django is trying to connect to a psql database where the only DATABSES configuration in the application is for sqlite3. 我不知道为什么django试图连接到psql数据库,其中应用程序中唯一的DATABSES配置是针对sqlite3的。

Could this be due to a dependency? 这可能是由于依赖关系造成的吗?

Try this, 尝试这个,

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

This might be helpful for you. 这可能对您有帮助。

Django only uses DATABASES setting to generate migrations using a specific database driver. Django仅使用DATABASES设置来使用特定的数据库驱动程序生成迁移。 I believe somewhere, there is an import which is overriding your DATABASES setting. 我相信某个地方有一个导入将覆盖您的DATABASES设置。 These are possible places to look for debugging in order of priority. 这些是按优先级顺序查找调试的可能位置。

  1. Any import into settings.py file after you set DATABASES variable which might override it. 设置DATABASES变量后,任何导入settings.py文件的操作都可能会覆盖它。
  2. if above is not the case, Some dependency must be overriding this setting manually. 如果不是上述情况,则必须手动某些依赖项覆盖此设置。 you might want to look into your INSTALLED_APPS . 您可能需要查看INSTALLED_APPS
  3. If still not enough, you might need to look at any other dependency that you are using in your project which tries to interact with django. 如果还不够,您可能需要查看项目中尝试与django进行交互的任何其他依赖项。

暂无
暂无

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

相关问题 psycopg2.OperationalError:fe_sendauth:未提供密码 - psycopg2.OperationalError: fe_sendauth: no password supplied SQLAlchemy (psycopg2.OperationalError) fe_sendauth:未提供密码 - SQLAlchemy (psycopg2.OperationalError) fe_sendauth: no password supplied AWS-DJANGO-格式错误:OperationalError:fe_sendauth:未提供密码 - AWS - DJANGO - Error in formatting: OperationalError: fe_sendauth: no password supplied Python 和 Postgresql:OperationalError:fe_sendauth:未提供密码 - Python and Postgresql: OperationalError: fe_sendauth: no password supplied Django 4 使用密码文件连接到 Postgresql:“fe_sendauth:未提供密码” - Django 4 connection to Postgresql using passfile: "fe_sendauth: no password supplied" PostgreSQL错误-psql:fe_sendauth:未提供密码 - PostgreSQL Error - psql: fe_sendauth: no password supplied Django fe_sendauth:未提供密码错误,无法连接到 postgres 数据库 - Django fe_sendauth: no password supplied error, unable to connect to postgres database django.db.utils.OperationalError:fe_sendauth:迁移 django 应用程序时未提供密码 - django.db.utils.OperationalError: fe_sendauth: no password supplied when migrating django app Docker- django 在连接到 postgres 时抛出错误:psycopg2.OperationalError:无法连接到服务器:连接被拒绝 - Docker- django throws error while connecting to postgres: psycopg2.OperationalError: could not connect to server: Connection refused 数据库不存在(psycopg2.OperationalError) - DATABASE NOT EXIST (psycopg2.OperationalError)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM