Python 在密码中使用URL特殊敏感字符时出现Postgres数据库连接问题

Python 在密码中使用URL特殊敏感字符时出现Postgres数据库连接问题,python,postgresql,psycopg2,peewee,Python,Postgresql,Psycopg2,Peewee,在尝试连接到PosgresQL数据库时,我遇到了一个身份验证错误。问题是,当密码中使用URL特殊敏感字符时,Peewee解析连接URL的方法会中断 以下内容不适用于身份验证错误: from peewee import * from playhouse.db_url import connect url = "postgresql://host:port/database_name?user=username&password=123#456" # or even u

在尝试连接到PosgresQL数据库时,我遇到了一个身份验证错误。问题是,当密码中使用URL特殊敏感字符时,Peewee解析连接URL的方法会中断

以下内容不适用于身份验证错误:

from peewee import *
from playhouse.db_url import connect

url = "postgresql://host:port/database_name?user=username&password=123#456"
# or even
url = "postgresql://host:port/database_name?user=username&password=123%456"
db = connect(url)
但是,这将起作用:

from psycopg2 import connect

db = connect(url)

我在公司工作,因此密码有很强的要求,包括强制使用特殊字符。有没有一种方法可以对这些字符进行编码,以便它们与
playhouse.db_url
的连接实现一起工作?

不要使用这种格式,请尝试
postgresql://:@://
@sahasrara62谢谢,如果我使用此替代url表单,问题是相同的。您是否尝试过url的查询部分?