I'm trying to connect to sql server from a different computer. I'm using the following code. The odbc driver is installed and also pyodbc is installed.
import pyodbc
server = 'SERVER'
database = 'DBNAME'
username = 'SA'
password = 'SQLPWD'
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
However I'm receiving the following error.
Traceback (most recent call last):
File "test.py", line 7, in <module>
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL
Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL
Server]Login failed for user 'SA'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC
Driver 17 for SQL Server][SQL Server]Login failed for user 'SA'. (18456)")
I'm not sure where I'm going wrong and the older questions have not been much helpful. I'm new to Python.






saaccount for your application. Also find out what the real error is from the SQL Server logs and then post that in an edit.;) or curly brackets ({or})?