I have a credential with a dollar sign and I suspect it ruins the connection string

I am using mssql+pyodbc to form a connection string in order to connect to a database. However a credential to our database contains a dollar sign and I believe it throws an error because the error says whatever the string of characters after the dollar sign in the credentials is a missing variable.

password = 'pass$word1234'
drivers = [item for item in pyodbc.drivers() if item.endswith(' for SQL Server')]
if drivers:
    driver = drivers[0]
else:
    raise Exception("No drivers available")

connection_string = f"mssql+pyodbc://{username}:{password}@{server}/{database}?driver={driver}&charset=utf&autocommit=true"

Hardcoding the password in the string has the same result.
sqlalchemy is installed, and adding a backslash causes an authentication issue.
I have a separate connection in a different project via pyodbc.connect using the same credentials with no backslash that can connect.
Using a different set of credentials without a dollar sign does work.

EDIT: It seems this used to be an issue in the legacy version https://github.com/great-expectations/great_expectations/issues/1927

Try password = 'pass\\$word1234'. I just had the same issue
Note: @Matt Allen originally posted this reply in Slack. It might not have transferred perfectly.

Yeah unfortunately using a backslash or double backslash results in pass\$word1234
I printed the connection string when using a double or single backslash and it always contains a single backslash in the connection string, which then causes a 28000 pyodbc error.

Interesting, it’s working for me with a postgres connection string, I wonder what the difference is
Note: @Matt Allen originally posted this reply in Slack. It might not have transferred perfectly.