Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping special characters in web2py database connection strings

Tags:

python

web2py

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?

like image 796
ChrisGuest Avatar asked Oct 06 '22 14:10

ChrisGuest


1 Answers

You should use decode_credentials option:

db = DAL('mysql://user1:P%40sswd@localhost/test', decode_credentials=True)
like image 171
drnextgis Avatar answered Oct 10 '22 04:10

drnextgis