First we need to connect to the SQL Server – pyodbc.connect()
. This method expects a string containing the server access information, such as servername, driver, port, ssl certificate, database name, username and password.
connection = pyodbc.connect('DRIVER={SQL Server};SERVER=' + server +
';DATABASE=' + database + ';UID=' + username + ';PWD=' + password)