Last active
March 25, 2020 09:24
-
-
Save diegoquintanav/c452b0f825cc341b1b7a3ad82569bf6d to your computer and use it in GitHub Desktop.
Build connection string of MSSQL Azure Databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask_sqlalchemy import make_url | |
from urllib.parse import quote_plus | |
def build_connection_string(**params): | |
""" | |
Return the url for MSSQL Azure DB Instances | |
""" | |
connection_string = quote_plus( | |
("DRIVER={driver};" | |
"SERVER={server};" | |
"DATABASE={database};" | |
"UID={username};" | |
"PWD={password}").format(**params)) | |
url = make_url("mssql+pyodbc:///?odbc_connect=%s" | |
% connection_string) | |
return url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment