SQLAlchemy 没有提供密码错误 [英] SQLAlchemy no password supplied error

查看:42
本文介绍了SQLAlchemy 没有提供密码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的错误,但我似乎找不到令人满意的解决方案.

This is probably a silly error but I cannot seem to find a satisfying solution.

运行 db.create_all() 时,出现以下错误.

When running db.create_all(), I got the following error.

sqlalchemy.exc.OperationalError: (OperationalError) fe_sendauth: no password supplied  None None

我的数据库链接设置为

'postgresql://localhost/db_name'

这在我的 Mac 和 Heroku 上运行良好,但在 ubuntu (digitalocean) 上就不行了.

This worked fine on my Mac and Heroku, but is not OK on ubuntu (digitalocean).

知道我可能做错了什么吗?

Any ideas what I might be doing wrong?

推荐答案

您可能只需要从连接字符串中删除localhost":

You probably just need to remove "localhost" from your connection string:

'postgresql:///db_name'

这告诉 psycopg2 使用 Unix 域套接字.您的默认配置将使用ident",因此您将以运行脚本的用户身份进行连接.在默认配置中,md5"仅适用于 TCP 连接.

That tells psycopg2 to use Unix-domain sockets. Your default configuration will use "ident" so you'll be connecting as the user that runs the script. In the default configuration, "md5" only applies to TCP connections.

这篇关于SQLAlchemy 没有提供密码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆