Hi, I have an issue where, after the using pyodbc, it takes several seconds for my process to exit.
The rest of the process runs quickly.. eg.. connect to database, execute the query, read the result, and close.. all finish in a fraction of a second. But then, sys.exit() takes several seconds, which is causing a problem.
I'm using python 3.6 on Windows Server 2008R2 and the database is
Pervasive 10.20.20 (not my choice.. it is part of the Sage 50 accounting system).
And I should mention, python is 32 bit because the Pervasive ODBC driver is 32 bit so it won't work otherwise.
My test code is below, any ideas would be appreciated, thanks!
Ben
#!python
import pyodbc, sys
db = pyodbc.connect('DSN=SSBCPEACH;UID=Peachtree;PWD=password')
cursor = db.cursor()
cursor.execute("""SELECT glacntnumber, accountdescription, accountid, accounttype FROM chart WHERE accountid = ? """, '10222')
account = cursor.fetchone()
if account is not None:
print("Found Account: AccountID '%s', AccountDescription '%s', AccountType '%s', GLAcntNumber '%s'." % (
account.AccountID, account.AccountDescription, account.AccountType, account.GLAcntNumber))
db.close()
print('closed')
# EXIT TAKES APPROX 3 SECONDS, only if I've connected to the database.
sys.exit(0)