I'm trying to do a connection to PostgreSQL 9.6 from Python 3.6 with Pycharm 2018.1.4 on Windows 10 with the connector psycopg2 in the version 2.7.5. I have the following code:
import os, psycopg2, psycopg2.extras
conexion = psycopg2.connect("dbname=Seguritec_BD user=SU host=localhost password=root port=5432")
psycopg2.OperationalError
cursor = conexion.cursor()
cursor.execute("Select * from Ejecutivos")
filas = cursor.fetchall()
It throws the next error:
Traceback (most recent call last):
File "D:/Documentos/Proyectos Pycharm/Graficos Drones/Login.py", line 3, in <module>
conexion = psycopg2.connect("dbname=Seguritec_BD user=SU host=localhost password=root port=5432")
File "D:\Documentos\Proyectos Python 3.5\lib\site-packages\psycopg2\__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError
It's an empty OperationalError, there's no description of the error.
Can you help me to understand and fix this error, please?
You have an issue so simplify it by first only using Postgresql to confirm your connection, first try psql only, substituting your values into the connection string
psql -U postgres -d postgres -c "SELECT * FROM pg_user;"
If you need reference
psql --help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.