我正在尝试使用psycopg2连接到本地PostgreSQL数据库(Windows 10)。
con = psycopg2.connect(
database="postgres",
user="postgres",
password="*******",
host="localhost",
port="5432"
)
我一直收到不太多的操作性错误:
---------------------------------------------------------------------------
OperationalError Traceback (most recent call last)
<ipython-input-8-198849577200> in <module>
----> 1 con = psycopg2.connect(
2 database="postgres",
3 user="postgres",
4 password="******",
5 host="localhost",
~\Anaconda3\envs\py38\lib\site-packages\psycopg2\__init__.py in connect(dsn, connection_factory, cursor_factory, **kwargs)
125
126 dsn = _ext.make_dsn(dsn, **kwargs)
--> 127 conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
128 if cursor_factory is not None:
129 conn.cursor_factory = cursor_factory
OperationalError:
尝试将“ localhost”替换为“ 127.0.0.1”,结果相同。 我在psql中看到具有5432端口和相同配置的数据库。 任何想法出了什么问题吗?