I have the following code which I have striped down to just included the part that is causing a crash in ArcMap.

import pymssql

# Connect to the Research db using Windows Integrated Authentication.
conn = pymssql.connect(host='', database='Research', trusted=True)

del conn

The first time this is run as a script from the toolbar works just fine. However if I run the script again it crashes ArcMap to crash. "ESRI has encounter a serious error and will now exit." Then asks if I want to submit error report...

Thoughts on what's happening? I thought closing the connection would be enough.

Do I need a Try/Exception statework work here. To handle if the connection is already made then don't override it?

Also, If someone knows where to find the ESRI report log on the computer I will upload mine.

  • It would be helpful to know what the exception message is here. Are you confident the connection is properly made in the first place? – TCopple May 29 '12 at 22:24
  • Yes, the connection works 110% the first time the script is run. I have it populating fields. Just when I run the script twice it fails. If anyone know how to output the exception message would be most helpful. – Tristan Forward May 29 '12 at 22:34
  • If you run JUST the code you placed above (and nothing else), does ArcMap still crash? – RyanKDalton Jul 3 '13 at 14:24

Try unchecking the "Run Python script in process" checkbox. (This can be found in the "Source" tab of your tool's Properties)

I'm running into the exact same problem using pyodbc 3.7. My script runs once and then crashes the second time it's run. Unchecking the aforementioned checkbox lets the script run multiple times without issue (but it seems to cause it to not work when published as a GP service).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.