<?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: Table.delete_features() RuntimeError:  Unable to Delete Features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677257#M52419</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks Joshua, I can delete by oids (and this is my workaround at the moment - I run table.query with time condition and then collect oids and delete with another call)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However since calls to arcgis are very expensive in terms of time I'd love to save one call if possible and run table.delete_features with query...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jan 2020 16:27:57 GMT</pubDate>
    <dc:creator>JamesKwong1</dc:creator>
    <dc:date>2020-01-07T16:27:57Z</dc:date>
    <item>
      <title>Table.delete_features() RuntimeError:  Unable to Delete Features</title>
      <link>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677255#M52417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Joshua, I was thinking about edit_features, I'll give it a go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Taking advantage of opportunity (please let me know if you'd prefer me to open new question) - I try to run something like this:&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;# below returns response suggesting query is correct&lt;/SPAN&gt;
table&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;validate_sql&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sql&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"my_timestamp_column &amp;lt; TIMESTAMP '2019-01-06 11:00:00'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# below throws exception&lt;/SPAN&gt;
table&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;delete_features&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"my_timestamp_column &amp;lt; TIMESTAMP '2019-01-06 11:00:00'"&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Line 5 fails with exception:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Traceback &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;most recent call last&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
File &lt;SPAN class="string token"&gt;"harvester/test/simulate_entry_point.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;40&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;module&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
route_event&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
File &lt;SPAN class="string token"&gt;"/lib/python3.8/site-packages/arcgis/features/layer.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1446&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; delete_features
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_con&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;post&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;delete_url&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; postdata&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; token&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_token&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
File &lt;SPAN class="string token"&gt;"/lib/python3.8/site-packages/arcgis/_impl/connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1183&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; post
self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_handle_json_error&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;resp_json&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'error'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; errorcode&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
File &lt;SPAN class="string token"&gt;"/lib/python3.8/site-packages/arcgis/_impl/connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1204&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; _handle_json_error
&lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; RuntimeError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;errormessage&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
RuntimeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 
Unable to delete features&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Error Code&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;400&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is only 40 items meeting criteria so should not be hitting any limits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this might be due to open-ended nature of the query (although I'd like arcgis to delete all features meeting criteria, I have seen posts here where people had to run multiple queries with bundles of ~2000 items).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677255#M52417</guid>
      <dc:creator>JamesKwong1</dc:creator>
      <dc:date>2021-12-12T04:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Table.delete_features() RuntimeError:  Unable to Delete Features</title>
      <link>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677256#M52418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the SQL validates and there are only 40 or so items, I don't think it is related to the query.&amp;nbsp; As a test, see if you can pass an OID using the deletes parameter.&amp;nbsp; If it throws the same error, then it is likely related to your permissions or service configuration.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jan 2020 16:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677256#M52418</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-01-07T16:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Table.delete_features() RuntimeError:  Unable to Delete Features</title>
      <link>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677257#M52419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks Joshua, I can delete by oids (and this is my workaround at the moment - I run table.query with time condition and then collect oids and delete with another call)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However since calls to arcgis are very expensive in terms of time I'd love to save one call if possible and run table.delete_features with query...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jan 2020 16:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677257#M52419</guid>
      <dc:creator>JamesKwong1</dc:creator>
      <dc:date>2020-01-07T16:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Table.delete_features() RuntimeError:  Unable to Delete Features</title>
      <link>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677258#M52420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The solution is to provide actual date in UTC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import datetime
from arcgis.gis import GIS
from arcgis.features import Table

g = GIS(username="my_user_name", password="my_secret")
pit = g.content.get('my_published_csv_item_id')
t = Table.fromitem(item=pit)

t.delete_features(where="my_datet_time_column &amp;lt; '{}'".format((datetime.datetime.utcnow() - datetime.timedelta(seconds=3600)).strftime("%Y-%m-%d %H:%M:%S")))
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:33:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-delete-features-runtimeerror-unable-to/m-p/677258#M52420</guid>
      <dc:creator>JamesKwong1</dc:creator>
      <dc:date>2021-12-12T04:33:18Z</dc:date>
    </item>
  </channel>
</rss>

