解决使用sqlalchemy时MySQL密码含有特殊字符问题
前言
当MySQL密码中含有特殊字符时,使用sqlalchemy大概率连不上,这时候就需要from urllib.parse import quote_plus as urlquote
。
示例代码
from sqlalchemy import create_engine
from urllib.parse import quote_plus as urlquote
mysql_password = "!@#$%^&*()"
eng = create_engine(f"mysql+pymysql://myuser:{urlquote(mysql_password)}@127.0.0.1:3306/dbtest")
本文来自博客园,作者:花酒锄作田,转载请注明原文链接:https://www.cnblogs.com/XY-Heruo/p/15874697.html