Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-09-2017, 03:27 PM   #1
LQ Newbie
Registered: Aug 2017
Location: Mexico
Distribution: Ubuntu 14.04, OS X High Sierra,
Posts: 16

Rep: Reputation: Disabled
Persistent db connection after waking up a computer from sleep?

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.

pyodbc.Error ('[08S01]', '[08S01] [Microsoft][ODBC Driver 13 for SQL Server]Communication link failure (0) (SQLEndTran)')
Here's how I declared the connection string:

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:

cur = db.cursor()
    query = "SELECT [ID] FROM [dbo].[Archive] WHERE [Number] = '%s'"
    cur.execute(query % (numberVariable))
    db_info = cur.fetchone()
    return db_info[0]
except Exception as e:
    print "Error 103: Error getting number in database"
Any help will be appreciated.
Old 10-09-2017, 07:25 PM   #2
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,505

Rep: Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080Reputation: 1080
Whenever you get this error, reopen your database-connection.
1 members found this post helpful.
Old 10-12-2017, 10:44 AM   #3
LQ Newbie
Registered: Aug 2017
Location: Mexico
Distribution: Ubuntu 14.04, OS X High Sierra,
Posts: 16

Original Poster
Rep: Reputation: Disabled
Found solution

Setting pyodbc.pooling = False, did the trick. Supposedly this option keeps persistent connection and I think that when the computer goes to sleep it interrupts the connection and throws the error message. Thank you for your answer!


mac, python, sql server

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
2016 MBP not waking up from sleep designator Linux - Laptop and Netbook 3 08-28-2017 11:50 AM
Black Screen when waking from a sleep Ubuntu 13.04 actyler1012 Linux - Newbie 1 05-19-2013 04:32 PM
WPA authentication fails after waking from sleep vs. dLink (Ubuntu 10.04) dewdrop_world Linux - Wireless Networking 3 05-12-2011 04:54 PM
Waking from S3 sleep doesn't turn the screen on (Asus A6U) MasterOfTheWind Linux - Laptop and Netbook 2 05-03-2011 02:06 AM
Waking my computer up after it goes to sleep Fosforo Ubuntu 4 01-20-2007 02:35 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration