D
D
Danil Samodurov2021-02-05 12:06:22
Python
Danil Samodurov, 2021-02-05 12:06:22

What causes a psycopg2.OperationalError when connecting to a PostgreSQL server?

Hello. With PostgreSQL, as well as in principle with the DBMS, I am familiar only in theory. Now I am practicing.
When trying to create a connection by the PostgreSQL database server in the following way

def create_connection():
    connection = psycopg2.connect(
        dbname='database',
        user='postgres',
        password='password',
        host='localhost',
        port='5432'
    )

The following error appears
File "C:\Program Files (x86)\Python38-32\lib\site-packages\psycopg2\__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError
Can't figure out why. Who will tell?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question