I'm attempting to access an SQL in python using pypyodbc, here is the code I've got:
import pypyodbc as pyodbc
db_host = host
db_name = name
db_user = user
db_password = password
connection_string = ("DRIVER={SQL Server};SERVER=" + (db_host) + ";DATABASE=" + (db_name) + ";UID=" + (db_user) + ";PWD=" + (db_password) + ";Trusted_Connection=yes;")
db = pyodbc.connect(connection_string)
When I try connecting I get the following error:
pypyodbc.DatabaseError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.')
I have tried changing the connection string in a number of different ways, but it still produduces the same error each time. This is work for a school project, and such I am trying to access the SQL server from the school system, and so the only thing I can think of that would mess it up is that there is a problem with the firewall and connection or something.
Any help or suggestions would be greatly appreciated. Cheers.
Connection string is correct.
Check
host
,name
,user
andpassword
.