I need to add a wild card to a urllib.parse.quote_plus
command but I am unclear how to.
When I execute the following on my flask server, I get the following error:
JavaScript
x
2
1
ValueError: unsupported format character 'D' (0x44) at index 8
2
How might I add a wildcard in here to accept an object?
JavaScript
1
4
1
user_email = 'my_email@xd.com'
2
params = urllib.parse.quote_plus("Driver={ODBC Driver 17 for SQL Server};Server=tcp:dbhere.database.windows.net,1433;Database=dbhere;Uid=%s;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=15;Authentication=ActiveDirectoryIntegrated")
3
params.replace('%s;', user_email)
4
JavaScript
1
3
1
# result
2
'Driver%3D%7BODBC+Driver+17+for+SQL+Server%7D%3BServer%3Dtcp%3Adbhere.database.windows.net%2C1433%3BDatabase%3Ddbhere%3BUid%3D%25s%3BEncrypt%3Dyes%3BTrustServerCertificate%3Dno%3BConnection+Timeout%3D15%3BAuthentication%3DActiveDirectoryIntegrated'
3
Advertisement
Answer
i think you should do the replacing first
JavaScript
1
3
1
user_email = 'my_email@xd.com'
2
params = urllib.parse.quote_plus("stuff;Uid=%s;stuff" % user_email)
3
or
JavaScript
1
2
1
params = urllib.parse.quote_plus(f"stuff;Uid={user_email};stuff")
2