psycopg2看不到我的PostgreSQL实例 [英] psycopg2 can't see my PostgreSQL instance
本文介绍了psycopg2看不到我的PostgreSQL实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Windows上,安装了32位python 2.6.6和psycopg2。
I'm on Windows, with a 32bit install of python 2.6.6 and psycopg2.
当psycopg2尝试连接时,它会得到 OperationalError
:
When psycopg2 tries to connect, it gets an 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
我能够使用 127.0.0.1:5432
上的pgAdmin3连接到PostgreSQL实例。
I am able to connect to PostgreSQL instance with pgAdmin3 on 127.0.0.1:5432
.
有什么想法吗?
推荐答案
conn = psycopg2.connect("dbname=your_database user=postgres password=xxxx host=127.0.0.1 port=5432")
这篇关于psycopg2看不到我的PostgreSQL实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文