【发布时间】: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