odon...@yahoo.com
unread,Jan 12, 2012, 9:52:46 AM1/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyodbc
I am using pyodbc to write SQL statements for SELECT, UPDATE, and
INSERT functions for an MS Access database. Everything works, but it
appears that the connection to the database does not close properly.
Basically this is what happens. I open a DB connection, query the
tables to make sure specific tables exist, close the database, and
then I use a different module (an ESRI arcpy GIS mapping module). When
I use this module, python crashes and I get the following error:
Message File Name Line Position
Traceback
__call__ C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc
\core\netref.py 123
syncreq C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc\core
\netref.py 45
sync_request C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc
\core\protocol.py 343
serve C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc\core
\protocol.py 305
_recv C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc\core
\protocol.py 265
recv C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc\core
\channel.py 36
read C:\Program Files\PyScripter\Lib\rpyc-python2x.zip\rpyc\core
\stream.py 105
exceptions.EOFError: [Errno 10054] An existing connection was forcibly
closed by the remote host
It seems that this has occurred in the past with pyodbc and the fix
was to disable pooling, but this did not work.I am using python 2.6
and pyodbc-3.0.2.win32-py2.6. I tried several older versions of pyodbc
but I get the same error message.
Any thoughts or has anyone else had this problem? It seems that
sqlalchemy no longer supports MS Access DB connections and pyodbc is
the best supported module currently available.
Also, I am actually able to make changes to the database and I use
this package alone it seems to work fine (e.g., I can loop through the
below code 100 times and I do not get an error). But I can also run my
other code successfully as long as I do not use pyodbc. There seems to
be some kind of conflict. I tried to use performance monitor to look
at the odbc connections, but I am not familiar with tracking this info
for Access and not sure how to determine if there is a thread or
socket connection to the database after I close.
Example of pyodbc code:
import pyodbc
pyodbc.pooling = False
conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb,
*.accdb)};DBQ=" + OutputDB, autocommit = True)
cur = conn.cursor()
for iTbl in Tbl_List:
if cur.tables(table=iTbl).fetchone():
pass
else:
print "Table in DB for Archive Project does not match
table scheme in python script--need to investigate.", iTbl
sys.exit(1)
conn.commit()
conn.close()
del conn