6

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?

Maddy
  • 791
  • 1
  • 8
  • 22
  • 2
    Sorry, I can't post comments but this may help: http://stackoverflow.com/questions/14335978/handle-in-mongodb-connection-string – Jason Clair May 01 '14 at 11:50

1 Answers1

15

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 @

Community
  • 1
  • 1
Jeff Epler
  • 502
  • 2
  • 7