<?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: ListTables returns Database Synonyms and ListFields Does not recognize them in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200802#M15450</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could try describing the table prior to the list fields. Once the object is described, look for the dataset ID (DSID) property. Anything not registered with the geodatabase will return -1. If the value doesn't equal or is greater than -1, perform the arcpy.ListFields() operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; tblList = arcpy.ListTables()
&amp;gt;&amp;gt;&amp;gt; for tbl in tblList:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(tbl)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print desc.DSID
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
-1&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:59:36 GMT</pubDate>
    <dc:creator>ChristianWells</dc:creator>
    <dc:date>2021-12-11T09:59:36Z</dc:date>
    <item>
      <title>ListTables returns Database Synonyms and ListFields Does not recognize them</title>
      <link>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200801#M15449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working in an enterprise SDE database.&amp;nbsp; I am working with a particular schema that contains tables, views and synonyms that have and have not been registered with the SDE and the Geodatabase.&amp;nbsp; Ultimately, I am trying to retrieve domains that are being used in the schema, but I have ran into an issue along the way.&lt;/P&gt;&lt;P&gt;The schema contains database synonyms.&amp;nbsp; I have found that arcpy.ListTables will return the database synonym, but arcpy.ListFields will not recognize the database synonym.&amp;nbsp; I would like to exclude the synonyms from my process, but arcpy.ListTables does not provide a utility to filter the return set by object type (info and dbase do not work in this case).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my specific example which I have abbreviated to highlight the issue.&amp;nbsp; The MYSCHEMA.RESERVOIR object is a database synonym:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;tableList = arcpy.ListTables()
for table in tableList:&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; if "MYSCHEMA." in table:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "RESERVOIR" in table:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print table
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = arcpy.ListFields(table) ## code breaks here
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "made it here"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fieldList:
&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;&amp;nbsp;&amp;nbsp; print table

MYSCHEMA.RESERVOIR


Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;pyshell#71&amp;gt;", line 6, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldList = arcpy.ListFields(table)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 1119, in ListFields
&amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.listFields(dataset, wild_card, field_type)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 344, in listFields
&amp;nbsp;&amp;nbsp;&amp;nbsp; self._gp.ListFields(*gp_fixargs(args, True)))
IOError: "MYSCHEMA.RESERVOIR" does not exist

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it appears that ListFields will not recognize a database synonym.&amp;nbsp; Does anyone have any thoughts about how to filter out database synonyms before running arcpy.ListFields?&amp;nbsp; I would prefer not to filter out the synonym objects by name, as these names could change and that would require someone to update the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;- Jake&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200801#M15449</guid>
      <dc:creator>JakeMatthys</dc:creator>
      <dc:date>2021-12-11T09:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: ListTables returns Database Synonyms and ListFields Does not recognize them</title>
      <link>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200802#M15450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could try describing the table prior to the list fields. Once the object is described, look for the dataset ID (DSID) property. Anything not registered with the geodatabase will return -1. If the value doesn't equal or is greater than -1, perform the arcpy.ListFields() operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; tblList = arcpy.ListTables()
&amp;gt;&amp;gt;&amp;gt; for tbl in tblList:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(tbl)
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print desc.DSID
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
-1&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200802#M15450</guid>
      <dc:creator>ChristianWells</dc:creator>
      <dc:date>2021-12-11T09:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: ListTables returns Database Synonyms and ListFields Does not recognize them</title>
      <link>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200803#M15451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christian,&lt;/P&gt;&lt;P&gt;Thanks for the response, but that didn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my example.&amp;nbsp; I've included 3 different types of database objects.&amp;nbsp; I have a registered table (CUSTOMER_INFO), I have a non-registered view (SP_XY) and a synonym (RESERVOIR).&amp;nbsp; The registered table and non-registered view return expected results, but the synonym is not recognized as a table object by arcpy.describe, therefore it returns an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;tableList = arcpy.ListTables()
for table in tableList:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "MYSCHEMA." in table:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "RESERVOIR" in table or "SP_XY" in table or "CUSTOMER_INFO" in table:&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;&amp;nbsp;&amp;nbsp; print table
&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;&amp;nbsp; desc = arcpy.Describe(table)
&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;&amp;nbsp; print desc.dsid


&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;&amp;nbsp; 
MYSCHEMA.CUSTOMER_INFO
100384
MYSCHEMA.SP_XY
-1
MYSCHEMA.RESERVOIR


Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;pyshell#1&amp;gt;", line 5, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(table)
&amp;nbsp; File
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;pyshell#1&amp;gt;", line 5, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(table)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 1234, in Describe
&amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.describe(value)
&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe
&amp;nbsp;&amp;nbsp;&amp;nbsp; self._gp.Describe(*gp_fixargs(args, True)))
IOError: "MYSCHEMA.RESERVOIR" does not exist
 "C:\Program Files (x86)\ArcGIS\Desk





top10.2\arcpy\arcpy\__init__.py", line 1234, in Descri&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion.&lt;/P&gt;&lt;P&gt;- Jake&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:59:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/listtables-returns-database-synonyms-and/m-p/200803#M15451</guid>
      <dc:creator>JakeMatthys</dc:creator>
      <dc:date>2021-12-11T09:59:39Z</dc:date>
    </item>
  </channel>
</rss>

