when you connect to mongodb using python from SQLAlchamey, we use
mongodb://username:password@host/database
If my password is P@ssword
, how can I escape the @
letter.
In my case it is breaking the connection because of this.
Other than changing the password is there any way?
Assuming that URLs in the mongodb scheme function like normal URLs, the password part must be URL-encoded. Specifically, @ would be encoded as %40. This quoting can be performed by Python's urllib:
>>> urllib.quote("P@ssword")
"P%40ssword"
Related: URL: Username with @
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With