Please let me know.The psycopg2 returns an error.
Source code is
#-*-coding:utf-8-*-
import psycopg2
if__name__=="__main__":
connector=psycopg2.connect(host="127.0.0.1", database="pdb", user="pgusr", port=532 , password="pgpsw")
cursor=connector.cursor()
sql = "insert into test_table values ('1', 'python')"
cursor.execute(sql)
sql = "insert into test_table values ('2', 'Pyson')"
cursor.execute(sql)
sql = "insert into test_table values ('3', 'pison')"
cursor.execute(sql)
connector.commit()
cursor.close()
connector.close()
In , the environment is python 2.7.11 on Windows.
What is the cause?Is it not possible to install only the Dalai Lama?
The error content is
Traceback (most recent call last): File "test105.py", line 7, in
connector=psycopg2.connect(host="127.0.0.1", database="pdb", user="pgusr", port=532 ,
password="pgpsw")File
"C:\Python27\lib\site-packages\psycopg2_init__.py", line 164, in
connect
conn=_connect(dsn, connection_factory=connection_factory, async=async) psycopg2.OperationalError: could not connect to server:
Connection refused (0x0000274D/10061)
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
The connection to PostgreSQL has failed, so please set up your environment to connect to PostgreSQL.
626 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
619 GDB gets version error when attempting to debug with the Presense SDK (IDE)
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.