SQLAlchemy (psycopg2.OperationalError) fe_sendauth: password not specified

I have an authentication problem when trying to connect to db postgres using sqlalchemy. This is how I connect:

db_url = 'postgresql+psycopg2:///<role>:<pass>@localhost:5432/basketball'
Engine = create_engine(db_url, echo=False)
SessionMaker = ORM.sessionmaker(bind=Engine, autoflush=False)
Session = ORM.scoped_session(SessionMaker)

Here is how I installed /etc/postgresql/9.3/main/pg_hba.conf

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Then when accessing db I get:

SQLAlchemy  (psycopg2.OperationalError) fe_sendauth: no password supplied 
+4
source share

Source: https://habr.com/ru/post/1627969/


All Articles