Skip to content

Instantly share code, notes, and snippets.

@diegoquintanav
Last active March 25, 2020 09:24
Show Gist options
  • Save diegoquintanav/c452b0f825cc341b1b7a3ad82569bf6d to your computer and use it in GitHub Desktop.
Save diegoquintanav/c452b0f825cc341b1b7a3ad82569bf6d to your computer and use it in GitHub Desktop.
Build connection string of MSSQL Azure Databases
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