【问题标题】:PostgreSQL connects through django but not wsgi, library has no ciphersPostgreSQL 通过 django 而不是 wsgi 连接,库没有密码
【发布时间】:2018-08-17 21:54:08
【问题描述】:

我正在尝试在我的 django 应用程序中连接到另一台服务器上的数据库,但我收到了错误(在我的 apache 错误日志中):

django.db.utils.OperationalError:无法创建 SSL 上下文: 图书馆没有密码

我可以使用 manage.py shell 并连接到这个数据库:

>>> import psycopg2
>>> conn = psycopg2.connect("dbname=mobilesurvey user=django password=xxx host=dugong-api-rmove.rsginc.com port=5432")

我该怎么做才能通过 django 实现这个功能?

【问题讨论】:

  • 你知道db是否需要ssl吗?
  • 是的,pg_hba.conf文件的连接类型为hostssl。

标签: django apache2 mod-wsgi psycopg2


【解决方案1】:

这个issue thread 有许多变通方法,但对我有用的是从源代码构建 psycopg2(执行 pip install -r requirements.txt,其中我的 requirements.txt 文件包括:psycopg2==2.7.4 --no-binary :all:)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-08
    • 1970-01-01
    • 2012-06-10
    • 2012-11-16
    • 2014-05-24
    • 1970-01-01
    • 2021-09-01
    • 2017-05-01
    相关资源
    最近更新 更多