rkallstrom

Example of pyodbc query to table

Discussion created by rkallstrom on Feb 24, 2012
I formerly had a model to update a domain that used a database connection to an Access query in an (*.accdb).  Unfortunately, I've been experiencing the same problems found at:

http://forums.arcgis.com/threads/4588-ArcGIS-Desktop-amp-MS-Access-Joined-Fields-Suddenly-Null-amp-Blob-Values

and bug NIM072996.

So since the simple way is no longer working, I'm thinking the best way would be to abandon trying to use a database connection and instead use pyodbc to pass the query to a dictionary, convert the dictionary to a table, then to the new domain, or more directly from dictionary to domain if possible.  Unfortunately, I've never worked with a dictionary type before, and I need examples of how to make the pyodbc object into a dictionary and then convert it to a dbf or some other table format. The SQL for the query is simple: "SELECT tblWorkers.WorkerID, [tblWorkers.LastName]&" "&[tblWorkers.FirstName] as FullName FROM tblWorkers WHERE (((tblWorkers.WeedTrkr)=True));"

Outcomes