<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy script using sqlalchemy and pandas only runs once in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275941#M21291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what parameters are set and what parameters are not set within the tool?&lt;/P&gt;&lt;P&gt;Also the lowercase issue...&amp;nbsp; lowercase is not a python method... lower is&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "UPPER"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a.lower()&lt;/P&gt;&lt;P&gt;'upper'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Aug 2016 15:55:39 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-08-08T15:55:39Z</dc:date>
    <item>
      <title>arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275938#M21288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am struggling with the following issue:&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;Here is what I basically do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="kwd"&gt;from&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; sqlalchemy &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; create_engine
&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pandas

&lt;/SPAN&gt;&lt;SPAN class="com"&gt;# set up sqlalchemy engine:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
engine &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; create_engine&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str"&gt;'mssql+pyodbc://[USER]:[PASSWORD]@[SERVER]/[DATABASE]?driver=SQL+Server'&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&lt;/SPAN&gt;&lt;SPAN class="com"&gt;# design query&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
query &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"some SELECT query here"&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
&lt;/SPAN&gt;&lt;SPAN class="com"&gt;# read data to pandas data frame&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
df &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pandas&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;read_sql_query&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;query&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; engine&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be great, thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: When I modify the script to force an error, fix this error and run it again, I get the following error message:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="typ"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="typ"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;...
&lt;CODE&gt;&lt;SPAN class="typ"&gt;File&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;"C:\Python27\lib\site-packages\sqlalchemy\sql\selectable.py"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; line &lt;/SPAN&gt;&lt;SPAN class="lit"&gt;2469&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;in&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; __init__&lt;/SPAN&gt;&lt;/CODE&gt;
&lt;SPAN class="pln"&gt;for c in columns:&lt;/SPAN&gt;
&lt;SPAN class="pln"&gt;&lt;CODE&gt;&lt;SPAN class="typ"&gt;AttributeError&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;:&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'tuple'&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; object has no attribute &lt;/SPAN&gt;&lt;SPAN class="str"&gt;'lowercase'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:26:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275938#M21288</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2021-12-11T13:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275939#M21289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"When I execute the tool within ArcGIS 10.3..."&amp;nbsp; It seems like your running the code from within an Toolbox?&amp;nbsp; If so, a regular Toolbox or Python Toolbox?&amp;nbsp; What if you run the code from the interactive Python window, what happens?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 13:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275939#M21289</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-08T13:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275940#M21290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, I run the script as Toolbox with some parameters to be set by the user.&lt;/P&gt;&lt;P&gt;When I execute the basic steps in the interactive Python console, it works fine, as it does within my IDE. Is there any difference between the script from a toolbox?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 13:58:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275940#M21290</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-08T13:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275941#M21291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what parameters are set and what parameters are not set within the tool?&lt;/P&gt;&lt;P&gt;Also the lowercase issue...&amp;nbsp; lowercase is not a python method... lower is&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a = "UPPER"&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; a.lower()&lt;/P&gt;&lt;P&gt;'upper'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 15:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275941#M21291</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-08T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275942#M21292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The parameters set are the server and database from which the data shall be read, paths and some text for the map title as well as the exporting format. Nothing special there. &lt;/P&gt;&lt;P&gt;I honestly have no idea what the 'lowercase' issue means, it occurs somewhere whithin the pandas module when executing the SELECT-query. To me, it seems like the pandas module opens the connection, defines a cursor object and then goes through the columns provided by the SELECT-query.&lt;/P&gt;&lt;P&gt;For the first time, everything is perfectly fine. When I run it a second time, it seems like the cursor-object is not overwritten, but appended to the first one, which causes the object to be a tuple. I don't know I'm right here, and the worst part: I have no clue how to get rid of that problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275942#M21292</guid>
      <dc:creator>RahelKreutz</dc:creator>
      <dc:date>2016-08-08T19:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275943#M21293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And you have added a simple 'del' to the scripts to delete the objects prior to completion?&amp;nbsp; I would assume that would be automatic on script completion, but I use numpy rather than pandas, so I can't comment on how it handles objects during script completion... some of it is a black box, but you would have to go through the github code to see what is going on with any particular function/module &lt;A href="https://github.com/pydata/pandas/tree/master/pandas" title="https://github.com/pydata/pandas/tree/master/pandas"&gt;pandas/pandas at master · pydata/pandas · GitHub&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 20:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275943#M21293</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-08T20:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275944#M21294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I delete all objects that matter in that case, specifically the data frame after exporting the data and the engine after the data is retrieved. From my understanding, pandas as well as sqlalchemy are taking care of committing, rollback, close and everything else, but obviously, I missed something at some point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But since you mention numpy: what I basically do is, I select data into the pandas data frame and do everything else there, which means I group the data based on a columnn specified by the user and export the resulting table as a csv-file. Can you do the same thing with numpy? I specifically worry about the grouping...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275944#M21294</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-09T06:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275945#M21295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;by group, do you basically mean that you basically do an argsort, then export to csv or are you doing a query, then exporting to a csv? Yes you can.&amp;nbsp; It would help if you just posted a snip of the attributes table and what you are querying for... maybe even whip in a pandas method or two so I can see what you are doing and why you are using the sqlalchemy.&amp;nbsp; I have written extensively on using numpy in my blog and elsewhere so it would be easier to work from example data to narrow down my search.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:50:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275945#M21295</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-09T06:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275946#M21296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think we're getting a little bit off-track here... using numpy instead of pandas is another topic, on which I will check out your blog to find out whether I switch to numpy or not. But for my initial issue, the problem occurs within the function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;df = pandas.read_sql_query(query&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;engine)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where my engine setup looks like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from sqlalchemy import create_engine
engine = create_engine(&lt;SPAN style="color: #a5c261;"&gt;'mssql+pyodbc://[USER]:[PASSWORD]@[SERVER]&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;/[DATABASE]&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;?driver=SQL+Server'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the basic problem is: why does the tool work fine at the first run, but does nothing on the second run? And why does pandas create a tuple-cursor-object (this is what I think is happening)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3924"&gt;@Dan&lt;/a&gt;: I will have a look at your blog and see if&amp;nbsp; numpy is sufficient for my purposes. I'm basically doing a simple SELECT-query (not SELECT INTO), so I don't think the problem is within the query itself, but in the way pandas deals with connections and cursors&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:26:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275946#M21296</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2021-12-11T13:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275947#M21297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;So the basic problem is: why does the tool work fine at the first run, but does nothing on the second run?&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you tried closing your connections to the sql db?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 14:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275947#M21297</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-08-09T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275948#M21298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing this to get rid of the connection (I'm using an engine, not the connection itself):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;engine.dispose()
del engine&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my understanding, this should do the job (an engine has no particuclar method &lt;SPAN style="color: #e23d39;"&gt;&lt;EM&gt;.close()&lt;/EM&gt;&lt;/SPAN&gt;).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:26:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275948#M21298</guid>
      <dc:creator>RahelKreutz</dc:creator>
      <dc:date>2021-12-11T13:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275949#M21299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you are correct.&amp;nbsp; I did see reference to the notion that it's actually a pool of connections and you could issue a .close() to each/all.&amp;nbsp; But also read that your .dispose() should be handling the disconnect.&amp;nbsp; As a test I'd run a simple SELECT statement to see if you are getting the same strange result of only working on the first pass.&amp;nbsp; If it works as expected, then perhaps the issue is at the db-level.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 15:24:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275949#M21299</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-08-09T15:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275950#M21300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, are you deleting the pandas DataFrame?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 15:29:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275950#M21300</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-08-09T15:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275951#M21301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are your script properties?&amp;nbsp; For example, with the General tab, are "Store relative path names..." and "Always run in foreground" checked?&amp;nbsp; On the Source tab, is "Run Python script in process" checked?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArcMap's Geoprocessing Options dialog, is "Background Processing" enabled?&amp;nbsp; Have you installed 64-bit Background Geoprocessing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ginned up a little script modeled after yours.&amp;nbsp; Since I don't know what your code does once it generates the Panda dataframe, I just dump some of the dataframe content as a message using &lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.AddMessage()&lt;/SPAN&gt; .&amp;nbsp; No matter how often I run it, I get the results I expect dumped as a message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without knowing a bit more of the script settings and what is being done with the Panda dataframe, I am all out of ideas. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 21:50:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275951#M21301</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-09T21:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275952#M21302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, those options are checked within the toolbox settings as well as in the Geoprocessing Options. With simple print-debugging (print some message after each step), I came to the conclusion that the error occurs within the aforementioned function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1470809842022479" data-renderedposition="86_8_1332_16" jivemacro_uid="_1470809842022479" modifiedtitle="true"&gt;&lt;P&gt;df = pandas.read_sql_query(query, engine)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting the pandas data frame as well as the engine which connects to the database don't do the job, so maybe you're right and the error occurs within the db. But if so, why does it work from the console as often as I like?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe one more piece of information (since this is an internal company project, unfortunately I can't be too specific here): I run the database connection and querying from a function which I will attach here. As you can see there, I'm also trying to check whether the engine already exists, but the result is still the same. I'm out of ideas...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 06:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275952#M21302</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-10T06:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275953#M21303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I do delete everything I assign (at least I hope I did not oversee something). I'll create a simpler SELECT testcase and get back to you as soon as I can&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 06:28:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275953#M21303</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-10T06:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275954#M21304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I created a small test-case with only the very basic function and executed it in twi different ways:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. create a Toolbox (without any parameters set) and run it from there&lt;/P&gt;&lt;P&gt;2. run each single line in the ArcGIS Python Console&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;P&gt;1. The same problem occurs as described at the top of this thread. Only difference: the script runs twice and not once, but the third run simply hangs up.&lt;/P&gt;&lt;P&gt;2. perfectly fine, I can do whatever I want as often as I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the problem seems to come from the Toolbox and is not within the query or the database.&lt;/P&gt;&lt;P&gt;Here is my Toolbox-setup:&lt;/P&gt;&lt;P&gt;- Store relative path names&lt;/P&gt;&lt;P&gt;- Always run in foreground&lt;/P&gt;&lt;P&gt;- Run Python script in process&lt;/P&gt;&lt;P&gt;- Parameters: all given as string with one exception (folder), all read with arcpy.GetParameterAsText()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So nothing unusual here...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 08:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275954#M21304</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-10T08:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275955#M21305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;and there are no lock files being created by arcmap then? (confirm through windows explorer) If arcmap is open are you using a separate IDE or arcmap's?&amp;nbsp; If you are always using a separate python ide and the only difference is whether arcmap is open, then the culprit is arcmap and tracking that down needs viewing what is going on with the operating system.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 08:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275955#M21305</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-08-10T08:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275956#M21306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as I can see, there are no lock files created. I'm using an external IDE, but it does not matter whether I have it open or not.&lt;/P&gt;&lt;P&gt;Little step forward: now it runs twice and crashes when executed a third time... extremely strange&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 09:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275956#M21306</guid>
      <dc:creator>HendrikBernert1</dc:creator>
      <dc:date>2016-08-10T09:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy script using sqlalchemy and pandas only runs once</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275957#M21307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to reproduce the issue with your attached code.&amp;nbsp; I figured out why I didn't generate the errors yesterday.&amp;nbsp; Oddly enough, if I run the code once in the Interactive Python window in ArcMap, then I can run the script tool numerous times without errors.&amp;nbsp; If I run the script tool out of process, it runs fine also.&amp;nbsp; If I run it as a tool in a Python toolbox, instead of a script in a regular toolbox, it runs fine.&amp;nbsp; I tried cutting out sqlalchemy and pandas and using pyodbc only, same results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I can't explain what or why, everything points to a problem with in-process, regular Toolboxes.&amp;nbsp; It might be worth trying running out of process or converting to a Python Toolbox.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 15:41:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-script-using-sqlalchemy-and-pandas-only-runs/m-p/275957#M21307</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-08-10T15:41:10Z</dc:date>
    </item>
  </channel>
</rss>

