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.

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='000.000.0.0', database='Research', trusted=True)

conn.close()
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.

share|improve this question
    
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. –  TForward May 29 '12 at 22:34
    
If you run JUST the code you placed above (and nothing else), does ArcMap still crash? –  RyanDalton Jul 3 '13 at 14:24
add comment

1 Answer 1

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).

share|improve this answer
add comment

Your Answer

 
discard

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

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