I am struggling with the following issue:
I created a arcpy script in which I connect to a database via sqlalchemy and collect some data into a pandas data frame. When I execute the tool within ArcGIS 10.3., it works perfectly fine. However, when I try to run it a second time within the same ArcGIS-session, it does not proceed, does not react to cancelling and seems to do nothing at all.
Here is what I basically do:
<SPAN class="kwd">from</SPAN><SPAN class="pln"> sqlalchemy </SPAN><SPAN class="kwd">import</SPAN><SPAN class="pln"> create_engine
</SPAN><SPAN class="kwd">import</SPAN><SPAN class="pln"> pandas
</SPAN><SPAN class="com"># set up sqlalchemy engine:</SPAN><SPAN class="pln">
engine </SPAN><SPAN class="pun">=</SPAN><SPAN class="pln"> create_engine</SPAN><SPAN class="pun">(</SPAN><SPAN class="str">'mssql+pyodbc://[USER]:[PASSWORD]@[SERVER]/[DATABASE]?driver=SQL+Server'</SPAN><SPAN class="pun">)</SPAN><SPAN class="pln">
</SPAN><SPAN class="com"># design query</SPAN><SPAN class="pln">
query </SPAN><SPAN class="pun">=</SPAN><SPAN class="pln"> </SPAN><SPAN class="str">"some SELECT query here"</SPAN><SPAN class="pln">
</SPAN><SPAN class="com"># read data to pandas data frame</SPAN><SPAN class="pln">
df </SPAN><SPAN class="pun">=</SPAN><SPAN class="pln"> pandas</SPAN><SPAN class="pun">.</SPAN><SPAN class="pln">read_sql_query</SPAN><SPAN class="pun">(</SPAN><SPAN class="pln">query</SPAN><SPAN class="pun">,</SPAN><SPAN class="pln"> engine</SPAN><SPAN class="pun">)</SPAN>
As I said, for the first run, everything is fine. When I execute it again, nothing happens, not even an error message. Another strange thing: it looks like it works fine when I execute the code from my IDE's python console, I can run it as often as I like. Seems like the problem is either in the engine setup or within ArcGIS.
Any help would be great, thank you!
EDIT: When I modify the script to force an error, fix this error and run it again, I get the following error message:
...
<SPAN class="typ">File</SPAN><SPAN class="pln"> </SPAN><SPAN class="str">"C:\Python27\lib\site-packages\sqlalchemy\sql\selectable.py"</SPAN><SPAN class="pun">,</SPAN><SPAN class="pln"> line </SPAN><SPAN class="lit">2469</SPAN><SPAN class="pun">,</SPAN><SPAN class="pln"> </SPAN><SPAN class="kwd">in</SPAN><SPAN class="pln"> __init__</SPAN>
for c in columns:
<SPAN class="typ">AttributeError</SPAN><SPAN class="pun">:</SPAN><SPAN class="pln"> </SPAN><SPAN class="str">'tuple'</SPAN><SPAN class="pln"> object has no attribute </SPAN><SPAN class="str">'lowercase'</SPAN>