Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

So I made a script that takes data from an MSSQL database and inserts it into a featureclass. I added the script to a toolbox and am able to run the tool from within ArcMap 10.1. The problem is that I cannot re-run the tool. When I try and run it a second time, ArcMap crashes. I'll start ArcMap again, run the tool and when I try and run it the second time ArcMap crashes again.

By calling arcpy.AddMessage() coupled with time.sleep(5) I have narrowed the problem down to one line of code: pyodbc_cursor.execute("{call dbo.GetData(?)}",(DataID))

It seems like even though I close() and del all my pyodbc variables (connection, cursor, row) after I'm done with them the cursor is causing a problem when the script is executed the second time around.

EDIT: This seems like some kind of bug between ArcMap, arcpy and pyodbc

share|improve this question
    
Ok so unchecking the 'Run Python script in process' seems to fix this issue and I can run the script more than once without ArcMap crashing. I don't think this is a good answer since it doesn't really answer why ArcMap would crash on the second execution of a pyodbc cursor that was closed and deleted. –  Samuel Henderson Mar 22 '13 at 18:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.