postgresql - 无法连接到 azure postgresql - 用户名应采用 <用户名@主机名> 格式

标签 postgresql azure sqlalchemy ckan

我正在尝试使用 azure PostgreSQL 进行 CKAN (ckan.org) CKAN 正在使用 http://www.sqlalchemy.org/用于数据库连接。

连接字符串如下所示:

engine = create_engine('postgresql://scott:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94e0fdf3f1e6d4f9edfcfbe7e0bae4fbe7e0f3e6f1e7baf0f5e0f5f6f5e7f1baf5eee1e6f1baf7fbf9" rel="noreferrer noopener nofollow">[email protected]</a>:5432/mydatabase')

语法为:

postgresql://username:password@hostname:5432/databasename

当尝试连接到 azure postgresql 时,我收到此错误:

FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in username@hostname format.

如果我尝试使用这样的用户名格式:

postgresql://scott@myhost:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="32465b555740725f4b5a5d41461c425d4146554057411c56534653505341571c53484740571c515d5f" rel="noreferrer noopener nofollow">[email protected]</a>:5432/mydatabase

然后我得到:

invalid port number: "[email protected]:5432"

有人解决这个问题了吗?

最佳答案

端口号无效是由用户名中的@引起的。

连接 URL 应如下所示:

postgresql://scott%40myhost:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="512538363423113c28393e22257f213e2225362334227f35302530333022347f302b2423347f323e3c" rel="noreferrer noopener nofollow">[email protected]</a>:5432/mydatabase

关于postgresql - 无法连接到 azure postgresql - 用户名应采用 <用户名@主机名> 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49521984/

相关文章:

mysql - Postgresql 模式匹配 utf 8

sql - 从表中选择特定月份的值包含时间戳列

sql - 大表更新查询慢

azure - 当资源在主位置不可用时,如何在 Azure 资源管理器模板的辅助位置部署资源?

azure - 使用图形 API 在哪里存储用户元数据?

python - sqlalchemy 反射(reflect)表到 orm?

SQL反加入删除优化

azure - Azure ACS 的自定义登录页面不起作用

python - 如何将 MySQL SOUNDEX 函数与 SQLAlchemy 结合使用

python - SQLAlchemy , 属性错误 : 'tuple' object has no attribute 'foreign_keys'