<?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: ArcSDESQLExecute (arcpy) for stored proc in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483776#M27514</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example from the help docs:&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm"&gt;ArcSDESQLExecute—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=541e9567-7aec-43e8-9fe8-a92e954e1c4c&amp;amp;searchIndex=0"&gt;https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=541e9567-7aec-43e8-9fe8-a92e954e1c4c&amp;amp;searchIndex=0&lt;/A&gt;‌ &lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=cfbdcbe2-5f0d-436e-b26a-4f01ca453aeb&amp;amp;searchIndex=0"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=cfbdcbe2-5f0d-436e-b26a-4f01ca453aeb&amp;amp;searchIndex=0&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Feb 2017 17:13:13 GMT</pubDate>
    <dc:creator>George_Thompson</dc:creator>
    <dc:date>2017-02-17T17:13:13Z</dc:date>
    <item>
      <title>ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483775#M27513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;anyone has an example to call stored proc from ArcSDESQLExecute (arcpy)? any help will be greatly appreciated&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 17:08:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483775#M27513</guid>
      <dc:creator>sapnas</dc:creator>
      <dc:date>2017-02-17T17:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483776#M27514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an example from the help docs:&amp;nbsp;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/arcsdesqlexecute.htm"&gt;ArcSDESQLExecute—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=541e9567-7aec-43e8-9fe8-a92e954e1c4c&amp;amp;searchIndex=0"&gt;https://community.esri.com/groups/geodatabase?sr=search&amp;amp;searchId=541e9567-7aec-43e8-9fe8-a92e954e1c4c&amp;amp;searchIndex=0&lt;/A&gt;‌ &lt;A href="https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=cfbdcbe2-5f0d-436e-b26a-4f01ca453aeb&amp;amp;searchIndex=0"&gt;https://community.esri.com/community/developers/gis-developers/python?sr=search&amp;amp;searchId=cfbdcbe2-5f0d-436e-b26a-4f01ca453aeb&amp;amp;searchIndex=0&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 17:13:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483776#M27514</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2017-02-17T17:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483777#M27515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is an example for simple&amp;nbsp;sql statements not stored proc&amp;nbsp;which will not work in my case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 18:08:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483777#M27515</guid>
      <dc:creator>sapnas</dc:creator>
      <dc:date>2017-02-17T18:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483778#M27516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you find a way to execute stored procedures?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2017 17:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483778#M27516</guid>
      <dc:creator>StephanieWidas1</dc:creator>
      <dc:date>2017-11-08T17:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483779#M27517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread is old, but maybe this will help someone. I couldn't get this function to work. It kept returning True instead of rows. From the help doc we know what a Boolean return means. This isn't particularly helpful if you know a stored procedure returns rows. But at least it is something.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;....for statements that do not return rows, 
it will return an indication of the success or failure of the statement 
(True for success; None for failure).‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;When i turned to pandas as an alternative I received a similar error message from sqlalchemy:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;File &lt;SPAN class="string token"&gt;"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\sqlalchemy\engine\result.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1077&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; _non_result
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"This result object does not return rows. "&lt;/SPAN&gt;
sqlalchemy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ResourceClosedError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; This result object does &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; rows&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; It has been closed automatically&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This led me to a &lt;A class="link-bare" href="https://stackoverflow.com/questions/3563738/stored-procedures-with-sqlalchemy#comment59904036_3564604" rel="nofollow noopener noreferrer" target="_blank"&gt;stackoverflow comment&lt;/A&gt; that suggested using SET NO COUNT when working with stored procedures and sqlalchemy. I wondered if this might work with ArcSDESQLExecute. It didn't. But, it solved my problem with pandas. Here is an example if you want the result of a stored procedure and have hit a wall with this function.&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="comment token"&gt;# Dependencies: ArcGIS PRO 1.4.1 (Python 3.5.4)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Currently using python instance: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQLAlchemy and pyodbc were added manually to arcgis pro interface&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; urllib
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; sqlalchemy &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; sa
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; pd

&lt;SPAN class="comment token"&gt;#utilizing SET NOCOUNT&lt;/SPAN&gt;
sqlStatement &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SET NOCOUNT ON EXEC dbo.spPropCharaSelectByNBHD 312524"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#connection string pointing to DSN created with ODBC Data Source Admin&lt;/SPAN&gt;
params &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;parse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;quote_plus&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"DSN={yourDSNnameHERE};Trusted_Connection=yes"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

engine &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sa&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;create_engine&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"mssql+pyodbc:///?odbc_connect=%s"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; params&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#create pandas dataframe&lt;/SPAN&gt;
current_source &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read_sql_query&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sqlStatement&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;engine&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483779#M27517</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2021-12-11T21:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcSDESQLExecute (arcpy) for stored proc</title>
      <link>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483780#M27518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding SET NOCOUNT ON works for me to be able to call stored procedures using arcpy.ArcSDESQLExecute. This was last tested with version 10.5.1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Apr 2018 00:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcsdesqlexecute-arcpy-for-stored-proc/m-p/483780#M27518</guid>
      <dc:creator>RonnieRichards</dc:creator>
      <dc:date>2018-04-05T00:16:12Z</dc:date>
    </item>
  </channel>
</rss>

