Company
Date Published
Author
Mike Knoop
Word count
404
Language
English
Hacker News points
None

Summary

We use SQLAlchemy at Zapier to handle external database connections to various databases such as MySQL, MSSQL, PostgreSQL. Recently, we encountered a problem with our MSSQL connector where using a username or password with a plus sign (+) caused connection issues due to double URL encoding of the odbc_connect parameter in the SQLAlchemy connection string. The issue was resolved by properly URL encoding the odbc_connect parameter twice to avoid decoding errors and ensure correct password transmission. To connect to MSSQL with SQLAlchemy, we use a special connection string that includes extra variables encoded into the odbc_connect parameter. For example, our working code generates a mssql+pyodbc SQLAlchemy connection using the urllib.quote_plus function to URL encode the odbc_connect parameter twice.