Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I escape `@` letter from SQL password in connection URI [duplicate]

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?

like image 664
Maddy Avatar asked Dec 14 '22 23:12

Maddy


1 Answers

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 @

like image 91
Jeff Epler Avatar answered Dec 21 '22 23:12

Jeff Epler