gpt4 book ai didi

mysql - python中使用magic函数连接mysql时如何处理@at密码

转载 作者:行者123 更新时间:2023-11-29 15:21:39 41 4
gpt4 key购买 nike

我想在python中使用%sql魔术函数连接mysql:

语法如下:

%sql mysql://root:password@1234@127.0.0.1/database1

由于密码中有@

我尝试将 @ 替换为 %40,但仍然不起作用。

错误信息如下: enter image description here

最佳答案

不使用quote_plus对你有帮助吗?

>>> from urllib.parse import quote_plus
>>> quote_plus("mysql://root:password@1234@127.0.0.1/database1")
'mysql%3A%2F%2Froot%3Apassword%401234%40127.0.0.1%2Fdatabase1'

关于mysql - python中使用magic函数连接mysql时如何处理@at密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59346080/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com