我在 Windows 上,安装了 32 位的 python 2.6.6 和 psycopg2。
当 psycopg2 尝试连接时,它会得到OperationalError
:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> conn = psycopg2.connect("dbname=your_database user=postgres password=xxxx host=127.0.0.1:5432")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\site-packages\psycopg2\__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not translate host name "127.0.0.1:5432" to address: Unknown server error
我可以使用 pgAdmin3 连接到 PostgreSQL 实例127.0.0.1:5432
。
任何想法?