5

I am using web2py to connect to a db with an 'at' sign in the password, eg 'P@sswd' .

db = DAL('mysql://user1:P@sswd@localhost/test')

This gets interpreted as a connection to host 'sswd@localhost' using password 'P'.

I have tried the obvious URL escaping technique but this failed:

db = DAL('mysql://user1:P%40sswd@localhost/test')

Is there a resource that explains the escaping conventions used in these URL style connection strings?

ChrisGuest
  • 3,398
  • 4
  • 32
  • 53

1 Answers1

4

You should use decode_credentials option:

db = DAL('mysql://user1:P%40sswd@localhost/test', decode_credentials=True)
drnextgis
  • 2,194
  • 1
  • 25
  • 32
  • Hmm, why would this be needed btw? Shouldn't `'mysql://user1:P@sswd@localhost/test'` work out of the box? – Pacerier May 29 '19 at 13:39