I'm developing a python app for MAC that interacts with an SQL Server Database after some hardware tests. I have a text box that makes a query into a table on the database and returns if that information has been passed to the test previously or not.
One of the tests that the computer has to pass it's a 10 sleep cycle test.
The main problem here is that whenever I want to make a query again with that text box it throws me the following error.
Code:
pyodbc.Error ('[08S01]', '[08S01] [Microsoft][ODBC Driver 13 for SQL Server]Communication link failure (0) (SQLEndTran)')
Here's how I declared the connection string:
Code:
db = pyodbc.connect(driver='{ODBC Driver 13 for SQL Server}', host='servername', database='db', user='user', password='pass')
And here's a snippet of the code:
Code:
cur = db.cursor()
try:
query = "SELECT [ID] FROM [dbo].[Archive] WHERE [Number] = '%s'"
cur.execute(query % (numberVariable))
db_info = cur.fetchone()
cur.close()
db.commit()
return db_info[0]
except Exception as e:
cur.close()
db.commit()
print "Error 103: Error getting number in database"
Any help will be appreciated.