Using Python to print a "database view definition"?!

679
1
04-05-2018 02:30 PM
Rachel_R_Rodriguez
New Contributor II

I am attempting to interrogate an SQL Server Enterprise Geodatabase using Python. I want to obtain information for all features, relationships, tables etc. within said database. (I have only been using python for about a week. So please be detailed.) 

I am having an issue with the TableViews. When using the walk function, with a datatype of "Table", I can print the File Name, but not the WhereClause. (I can see the definition in the View Properties dialog box.) 

I'm not sure how 'off' I am in my procedure and syntax. I have been trying the following statement ||| desc = arcpy.Describe(TableViewName) print "Where Clause: " + desc.whereClause |||  (I pulled this from the TableView properties example on the ArcPy Help on ArcGIS.com.)

 Any ideas?! Thanks! 

1 Reply
JoshuaBixby
MVP Esteemed Contributor

Short answer is you can't, unfortunately.  The table view | Definition - Esri Support GIS Dictionary   isn't what you think it is, at least in terms of the Describe classes:

A representation of tabular data for viewing and editing purposes. The table view created when a table is added to ArcMap is a copy of the actual table data stored in memory.

The TableView is an ArcGIS object, not a database object.  Exploring the Describe—Help | ArcGIS Desktop property groups, one sees there is no group of properties for either "Database View" or just "View," which is what we would need to extract the SQL behind a database view.

Now you might be thinking, why does Walk—Help | ArcGIS Desktop return the database views when I pass datatype of "Table"?  I can't answer that question, maybe someone from Esri can weigh in on that one.