<?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: maintenance domains in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087050#M61978</link>
    <description>&lt;P&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;Hi, I'm thinking about how I could audit my domains in the SDE database using a python script.&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;I'd like to be able to: - create an inventory of existing domains - identify duplicates in domains - identify domains used in services - identify domain owners - extract domains in CSV format - remove duplicate domains not in use - automate this script to run once a month Has anyone thought about this problem or has a script that can do this &lt;A href="https://cancatseat.info/can-cats-eat-bananas/" target="_self"&gt;check&lt;/A&gt;?&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;Thank you in advance for your consideration.&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Aug 2021 11:36:33 GMT</pubDate>
    <dc:creator>chrisjordan9</dc:creator>
    <dc:date>2021-08-09T11:36:33Z</dc:date>
    <item>
      <title>Maintnance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087048#M61975</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I am thinking about how I could use a python script to audit my domains in the sde database.&lt;BR /&gt;I would like to be able to:&lt;BR /&gt;- make an inventory of the existing domains&lt;BR /&gt;-Identify duplicates in the domains&lt;BR /&gt;-Identify domains used in services&lt;BR /&gt;-identify the owners of the domains&lt;BR /&gt;- extract domains in CSV format&lt;BR /&gt;-remove duplicate domains not in use&lt;BR /&gt;- automate this script to run every month&lt;BR /&gt;Has anyone thought about this problem or has a script to do this?&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 10:40:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087048#M61975</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T10:40:24Z</dc:date>
    </item>
    <item>
      <title>maintenance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087046#M61977</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I am thinking about how I could use a python script to audit my domains in the sde database.&lt;BR /&gt;I would like to be able to:&lt;BR /&gt;- make an inventory of the existing domains&lt;BR /&gt;-Identify duplicates in the domains&lt;BR /&gt;-Identify domains used in services&lt;BR /&gt;-identify the owners of the domains&lt;BR /&gt;- extract domains in CSV format&lt;BR /&gt;-remove duplicate domains not in use&lt;BR /&gt;- automate this script to run every month&lt;BR /&gt;Has anyone thought about this problem or has a script to do this?&lt;BR /&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 10:41:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087046#M61977</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T10:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: maintenance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087050#M61978</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;Hi, I'm thinking about how I could audit my domains in the SDE database using a python script.&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;I'd like to be able to: - create an inventory of existing domains - identify duplicates in domains - identify domains used in services - identify domain owners - extract domains in CSV format - remove duplicate domains not in use - automate this script to run once a month Has anyone thought about this problem or has a script that can do this &lt;A href="https://cancatseat.info/can-cats-eat-bananas/" target="_self"&gt;check&lt;/A&gt;?&lt;/FONT&gt;&lt;/U&gt;&lt;BR /&gt;&lt;U&gt;&lt;FONT color="#3366FF"&gt;Thank you in advance for your consideration.&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 11:36:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087050#M61978</guid>
      <dc:creator>chrisjordan9</dc:creator>
      <dc:date>2021-08-09T11:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Maintnance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087071#M61983</link>
      <description>&lt;P&gt;@Anonymous User,&lt;/P&gt;&lt;P&gt;Here is a script that will list which domains are no longer in use.&amp;nbsp; This can be a good starting point to perform some of the other maintenance tasks you're looking to do.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, sys

# Variables
report = r"C:\Temp\Python\list_unused_domains.csv"
gdbConnection = r"C:\DBConnection\SQL SERVER - DBO@VECTOR.sde"

# Create report of domains not in use
with open(report, "w") as f:
    f.write("Domains not in use\n")

    # create list of domains
    domains = arcpy.da.ListDomains(gdbConnection)
    lst_names = [domain.name for domain in domains]

    # list featureclasses
    arcpy.env.workspace = gdbConnection
    lst_fds = arcpy.ListDatasets(feature_type="feature")
    lst_fds.append("")
    lst_doms = []
    for fds in lst_fds:
        lst_fc = arcpy.ListFeatureClasses(feature_dataset=fds)
        for fc in lst_fc:
            try:
                flds = arcpy.ListFields(os.path.join(gdbConnection, fds, fc))
                for fld in flds:
                    if fld.domain != "":
                        lst_doms.append(fld.domain)
            except:
                pass


    # process tables
    lst_tbl = arcpy.ListTables()
    for tbl in lst_tbl:
         try:
             flds = arcpy.ListFields(tbl)
             for fld in flds:
                 if fld.domain != "":
                    lst_doms.append(fld.domain)
         except:
             pass

    # create list of domains not in use
    lst_notinuse = list(set(lst_names) - set(lst_doms))

    # write to file
    for dom in lst_notinuse:
        f.write(f"{dom}\n")
print("Finished")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Aug 2021 13:23:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087071#M61983</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-08-09T13:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Maintnance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087073#M61984</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10527"&gt;@JakeSkinner&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;this will get me started.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 13:25:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087073#M61984</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-09T13:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Maintnance domains</title>
      <link>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087112#M61987</link>
      <description>&lt;P&gt;I also came up with a script that will delete unused domains. It should be a good starting point for doing the other things you mentioned.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/delete-unused-domains/td-p/145494" target="_blank"&gt;Delete Unused Domains - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 14:52:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/maintnance-domains/m-p/1087112#M61987</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-08-09T14:52:34Z</dc:date>
    </item>
  </channel>
</rss>

