I am trying to use string format() method to create a connection string.
Below is my code :
connStr = 'DRIVER={ODBC Driver 13 for SQL Server};SERVER={s};PORT=1443;DATABASE={d};UID={u};PWD={p}'.format(s = server, d = database, u = username, p = password)
It will get following error:
File ".\sqltest.py", line 9, in connStr = 'DRIVER={ODBC Driver 13 for SQL Server};SERVER={s};PORT-1443;DATABASE={d};UID={u};PWD={p}'.format(s = se rver, d = database, u = username, p = password) KeyError: 'ODBC Driver 13 for SQL Server\'