简体   繁体   English

SQLAlchemy (psycopg2.OperationalError) fe_sendauth:未提供密码

[英]SQLAlchemy (psycopg2.OperationalError) fe_sendauth: no password supplied

I'm having this authentication issue when trying to connect to a postgres db using sqlalchemy.尝试使用 sqlalchemy 连接到 postgres 数据库时遇到此身份验证问题。 This is how I'm connection:这是我的连接方式:

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)

This is how I set up /etc/postgresql/9.3/main/pg_hba.conf这就是我设置/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 the db I get:然后,在访问数据库时,我得到:

SQLAlchemy  (psycopg2.OperationalError) fe_sendauth: no password supplied 

As @univerio commented , the problem is the structure of the connection url.正如@univerio 评论的那样,问题在于连接 url 的结构。

The standard url structure is标准的 url 结构是

dialect+driver://username:password@host:port/database

The url网址

db_url = 'postgresql+psycopg2:///<role>:<pass>@localhost:5432/basketball'

describes a Postgresql database named <role>:<pass>@localhost:5432/basketball with no explicit credentials or hostname defined, hence the error message.描述了一个名为<role>:<pass>@localhost:5432/basketball的 Postgresql 数据库,没有定义明确的凭据或主机名,因此出现错误消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 psycopg2.OperationalError:fe_sendauth:未提供密码 - psycopg2.OperationalError: fe_sendauth: no password supplied AWS-DJANGO-格式错误:OperationalError:fe_sendauth:未提供密码 - AWS - DJANGO - Error in formatting: OperationalError: fe_sendauth: no password supplied Python 和 Postgresql:OperationalError:fe_sendauth:未提供密码 - Python and Postgresql: OperationalError: fe_sendauth: no password supplied Django psycopg2.OperationalError:fe_sendauth错误,但未连接到PostgreSQL数据库 - Django psycopg2.OperationalError: fe_sendauth error but not connecting to postgresql database fe_sendauth:Composer 中没有提供密码 - fe_sendauth: no password supplied in Composer django.db.utils.OperationalError:fe_sendauth:迁移 django 应用程序时未提供密码 - django.db.utils.OperationalError: fe_sendauth: no password supplied when migrating django app Django 4 使用密码文件连接到 Postgresql:“fe_sendauth:未提供密码” - Django 4 connection to Postgresql using passfile: "fe_sendauth: no password supplied" PostgreSQL错误-psql:fe_sendauth:未提供密码 - PostgreSQL Error - psql: fe_sendauth: no password supplied 将postgres作为Docker服务运行时,“psql:fe_sendauth:没有提供密码” - “psql: fe_sendauth: no password supplied” when running postgres as a Docker service Django fe_sendauth:未提供密码错误,无法连接到 postgres 数据库 - Django fe_sendauth: no password supplied error, unable to connect to postgres database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM