sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2003, "Can't connect to MySQL server on 'xxxx@localhost' ([Errno 11003] getaddrinfo failed)") 报错时,是因为密码是含有@字符导致,需要使用urllib.parse中导入quote_plus解决
例如:
from urllib.parse import quote_plus as urlquote dbConnect=create_engine(f'mysql+pymysql://{userName}:{urlquote(password)}@{dbHost}:{dbPort}/{dbName}?charset=utf8')
评论