I am taking a connection string from user input and am getting an error if the given string contains @,/,:, etc. So, how can I resolve it?
Example:
from sqlalchemy import create_engine
connection_string = "mssql+pymssql://demo:Testing@123@Server-name" # suppose this type of input given by the user.
engine = create_engine(connection_string)
print(engine.connect())
In the example above the password is "Testing@123" but sqlalchemy takes "Testing" as the password and "123@Server-name" as the server name.
I know about quote_plus but I think we need password separately and then we can do something like this: "mssql+pymssql://demo:%s@Server-name" % quote_plus("Testing@123") But I'm taking the full connection string as input so, anyone have any idea how I can handle it dynamically?