<?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: Listing all feature classes in an Enterprise Database in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235710#M66171</link>
    <description>&lt;P&gt;Thank you for trying the code.&lt;BR /&gt;Did it list the FeatureDatasets and the FeatureClasses inside Feature Datasets?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 23:54:23 GMT</pubDate>
    <dc:creator>Thiru_P</dc:creator>
    <dc:date>2022-11-28T23:54:23Z</dc:date>
    <item>
      <title>Listing all feature classes in an Enterprise Database</title>
      <link>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235260#M66168</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;TLDR; how do you create a list of data sets that lists everything in an enterprise geodatabase, schemawise?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to generate a list of all the data sets (e.g, relationship classes, tables, feature classes, including the feature classes within Feature Datasets) in an enterprise database in each schema (.sde connection file) periodically.&lt;/P&gt;&lt;P&gt;I have used the arcpy.da.Walk module with keyword "Any" and with each datatype mentioned; no success yet.&lt;/P&gt;&lt;P&gt;Software used:&lt;BR /&gt;Python 3.7.11&lt;BR /&gt;PostgresSQL 11.16&lt;BR /&gt;PostGIS 2.4.5&lt;BR /&gt;ArcSDE Geodatabase 10.7.1&lt;/P&gt;&lt;P&gt;This is the code that I tried so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-
"""
Lists the contents of Cloud Enterprise DataBase (CEDB) and writes into an MS Excel
Sorts in an alphabetical ascending order

Created on  09 May 2021
Last update 24 Nov 2022

@author: thiru
"""

#List the contents of CEDB UAT

#import modules
import arcpy
import pandas as pd
import re
import openpyxl

#assign maximum processing power
arcpy.env.parallelProcessingFactor = "100%"

###List the folder where the sde connection files are
sdeDir = r"C:/SDE/"

##CEDB schemas as sde connection files
workspaceList = [
"alpha@cedb(uat).sde",
"beta@cedb(uat).sde",
"gamma@cedb(uat).sde",
"theta@cedb(uat).sde"
]

vardatatype = [
'CadDrawing',
'CadastralFabric',
'Container',
'FeatureDataset',
'FeatureClass',
'GeometricNetwork',
'LasDataset',
'Layer',
'Locator',
'Map',
'MosaicDataset',
'NetworkDataset',
'PlanarGraph',
'RasterCatalog',
'RasterDataset',
'RelationshipClass',
'RepresentationClass',
'Style',
'Table',
'Terrain',
'Text',
'Tin',
'Tool',
'Toolbox',
'Topology'
]

#create empty sets, this will remove duplicates
files = []
schemas = []
#iterate through each schema and list contents
for ws in workspaceList:
    workspace = sdeDir + ws
    da_owner= ws[:ws.index("@")]
    print (workspace)
    schemas.append(workspace)
    for dt in vardatatype:
        walk = arcpy.da.Walk(workspace, datatype=[dt])
        for dirpath, dirnames, filenames in walk:
            for filename in filenames:
                filename.lower()
                filename = filename+"."+dt
                files.append(filename)
                print(filename)

df = pd.DataFrame(files)
print("Number of features", len(files))
print("Number of schemas", len(schemas))
#Check if dataframe is empty
if df.empty:
    print('List is empty!')
else:
    # dropping null value columns to avoid errors
    df.dropna(inplace = True)
    #Name the column name
    df.columns = ['LayerName']
    df[['DbName', 'SchemaName', 'Layer', 'DataType']] = df['LayerName'].str.split('.', expand=True)
    #Remove the redundant column
    df = df.drop(columns=['LayerName'])
    #Sort the columns based on Schema, LayerName
    df.sort_values(by=['SchemaName', 'Layer'], ascending=(True, True), inplace=True, ignore_index=True)
    df.to_excel(r"C:/Temp/Lists/CEDB_alltypes_Listing.xlsx", index = False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 01:21:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235260#M66168</guid>
      <dc:creator>Thiru_P</dc:creator>
      <dc:date>2023-03-22T01:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Listing all feature classes in an Enterprise Database</title>
      <link>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235312#M66169</link>
      <description>&lt;P&gt;Your code works perfectly for me. What problems do you encounter?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1669628025247.png" style="width: 483px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56935i43A74302DA540144/image-dimensions/483x52?v=v2" width="483" height="52" role="button" title="JohannesLindner_0-1669628025247.png" alt="JohannesLindner_0-1669628025247.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 09:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235312#M66169</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-11-28T09:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Listing all feature classes in an Enterprise Database</title>
      <link>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235710#M66171</link>
      <description>&lt;P&gt;Thank you for trying the code.&lt;BR /&gt;Did it list the FeatureDatasets and the FeatureClasses inside Feature Datasets?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 23:54:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235710#M66171</guid>
      <dc:creator>Thiru_P</dc:creator>
      <dc:date>2022-11-28T23:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Listing all feature classes in an Enterprise Database</title>
      <link>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235717#M66172</link>
      <description>&lt;P&gt;Does not add the Feature Dataset to the Excel file, but it finds them and adds the contained Feature Classes.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 00:14:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listing-all-feature-classes-in-an-enterprise/m-p/1235717#M66172</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-11-29T00:14:17Z</dc:date>
    </item>
  </channel>
</rss>

