Django + Psycopg2:InterfaceError:仅支持协议3 [英] Django + Psycopg2: InterfaceError: only protocol 3 supported

查看:52
本文介绍了Django + Psycopg2:InterfaceError:仅支持协议3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Django + Postgresql设置中加载页面时,偶尔会出现此错误,但并非总是如此:

When loading pages in my Django + Postgresql setup I occasionally get this error but not all the time:

psycopg2/__init__.py ? in connect

        raise TypeError('missing dsn and no parameters')
    else:
        dsn = " ".join(["%s=%s" % (k, _param_escape(str(v)))
            for (k, v) in items])
conn = _connect(dsn, connection_factory=connection_factory, async=async)
if cursor_factory is not None:
    conn.cursor_factory = cursor_factory
return conn

我绝对不知道

我的production.py设置文件:

My production.py settings file:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
            'NAME': 'mydbname',                      # Or path to database file if using sqlite3.
            # The following settings are not used with sqlite3:
            'USER': 'myuser',
            'PASSWORD': 'mypassword',
            'HOST': 'localhost',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
            'PORT': '',                      # Set to empty string for default.
        }
    }


推荐答案

< a href = http://initd.org/psycopg/docs/connection.html#connection.protocol_version rel = nofollow> http://initd.org/psycopg/docs/connection.html#connection.protocol_version

您未提供所使用的Postgres版本。

似乎早于7.4。
在这种情况下,解决方案是升级postgres
版本(或安装旧版本的psycopg,但我认为这样不好)

You didn't provide a version of postgres you are using.
Seems it's older than 7.4. In that case a solution will be to upgrade version of postgres
(or install older version of psycopg, but i think it's not good)

这篇关于Django + Psycopg2:InterfaceError:仅支持协议3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆