【问题标题】:Django + Psycopg2: InterfaceError: only protocol 3 supportedDjango + Psycopg2:InterfaceError:仅支持协议 3
【发布时间】:2014-10-02 16:46:19
【问题描述】:

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

连接中的psycopg2

InterfaceError: 仅支持协议 3

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 设置文件:

    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.
        }
    }

【问题讨论】:

  • 不确定它是否相关,但我在 Ubuntu 机器上出现共享内存问题后出现了这个问题。
  • 这仍然是一个问题。有没有人找到解决方案?我正在使用 Ubuntu,但不知道如何处理“共享内存问题”:/

标签: django postgresql


【解决方案1】:

http://initd.org/psycopg/docs/connection.html#connection.protocol_version

您没有提供您正在使用的 postgres 版本。
好像是7.4以上的。 在这种情况下,解决方案将是升级 postgres 版本
(或安装旧版本的 psycopg,但我认为这不好)

【讨论】:

    猜你喜欢
    • 2021-03-21
    • 1970-01-01
    • 2016-07-19
    • 2021-12-04
    • 2020-03-30
    • 1970-01-01
    • 2011-07-27
    • 1970-01-01
    相关资源
    最近更新 更多