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

Python SQLAlchemy(psycopg2.OperationalError)fe_sendauth:未提供密码,python,database,postgresql,sqlalchemy,Python,Database,Postgresql,Sqlalchemy,我在尝试使用sqlalchemy连接到postgres db时遇到此身份验证问题。 这就是我对连接的理解: db_url = 'postgresql+psycopg2:///<role>:<pass>@localhost:5432/basketball' Engine = create_engine(db_url, echo=False) SessionMaker = ORM.sessionmaker(bind=Engine, autoflush=False) Sessi

我在尝试使用sqlalchemy连接到postgres db时遇到此身份验证问题。 这就是我对连接的理解:

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)
然后,当访问数据库时,我得到:

SQLAlchemy  (psycopg2.OperationalError) fe_sendauth: no password supplied 
如前所述,问题在于连接url的结构

标准的url结构是

方言+driver://username:password@主机:端口/数据库
网址

db_url='postgresql+psycopg2://:@localhost:5432/basketball'

描述名为
:@localhost:5432/basketball
的Postgresql数据库,该数据库未定义明确的凭据或主机名,因此显示错误消息。

是否尝试删除URL中的一个斜杠?它应该只有两个斜杠(
//
),而不是三个(
//
)。
SQLAlchemy  (psycopg2.OperationalError) fe_sendauth: no password supplied