<?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: remove_datastore method in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1096195#M6601</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/43250"&gt;@MehdiPira1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your guidance. I was able to delete the registered datastore with the following code. I couldn't rely on datastore list index so I edited your code.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def delete_registered_ds(ds_name, gis):
    """
    :param ds_name: a string in datastore's name
    :param gis: a GIS class
    :return:
    """
    arcpy.AddMessage("Deleting the registered data store from GIS server...")

    gis_servers = gis.admin.servers.list()
    for gis_server in gis_servers:
        if "A_PORTAL_NAME" in gis_server.url.lower():
            data_store_list = gis_server.datastores.list()
            for ds in data_store_list:
                if ds.type == "egdb":
                    if ds_name.lower() in ds.path.lower():
                        ds.delete()
                        break&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Sep 2021 01:07:30 GMT</pubDate>
    <dc:creator>AzinSharaf</dc:creator>
    <dc:date>2021-09-08T01:07:30Z</dc:date>
    <item>
      <title>remove_datastore method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1094752#M6582</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DatastoreManager&lt;/STRONG&gt; class has &lt;EM&gt;add_database()&lt;/EM&gt; method but it seems it doesn't have the remove method. How can I remove an existing registered datastore item using this class or other arcgis api for python classes?&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.DatastoreManager" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.DatastoreManager&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 01:07:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1094752#M6582</guid>
      <dc:creator>AzinSharaf</dc:creator>
      <dc:date>2021-09-02T01:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: remove_datastore method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1094785#M6585</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/75018"&gt;@AzinSharaf&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The following code snippet unregisters a datastore:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis_servers = gis_portal.admin.servers.list()
# Select the relevant server
server1 = gis_servers[1]
dataStore_list = server1.datastores.list()
# select the datastore you want to unregister,let's say the 4th one
dataStore_list[3].delete()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that's helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 03:43:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1094785#M6585</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-09-02T03:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: remove_datastore method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1096195#M6601</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/43250"&gt;@MehdiPira1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your guidance. I was able to delete the registered datastore with the following code. I couldn't rely on datastore list index so I edited your code.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def delete_registered_ds(ds_name, gis):
    """
    :param ds_name: a string in datastore's name
    :param gis: a GIS class
    :return:
    """
    arcpy.AddMessage("Deleting the registered data store from GIS server...")

    gis_servers = gis.admin.servers.list()
    for gis_server in gis_servers:
        if "A_PORTAL_NAME" in gis_server.url.lower():
            data_store_list = gis_server.datastores.list()
            for ds in data_store_list:
                if ds.type == "egdb":
                    if ds_name.lower() in ds.path.lower():
                        ds.delete()
                        break&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 01:07:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1096195#M6601</guid>
      <dc:creator>AzinSharaf</dc:creator>
      <dc:date>2021-09-08T01:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: remove_datastore method</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1096200#M6602</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/75018"&gt;@AzinSharaf&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Not a problem. Glad that helped!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 01:25:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/remove-datastore-method/m-p/1096200#M6602</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-09-08T01:25:04Z</dc:date>
    </item>
  </channel>
</rss>

