Accessing features class of child version in ArcSDE using Python and arcpy

614
11
05-29-2018 10:50 AM
JAY_PRAKASHKUMAR
New Contributor III

Hello,

I want to access the feature class of my newly created Versioned dataset (child) created from the default SDE using arcpy

Thank you for your time

Tags (3)
0 Kudos
11 Replies
JoeBorgione
MVP Esteemed Contributor

Okay.  Utilize the connection string you've created to that version as the path that arcpy follows....

That should just about do it....
0 Kudos
VinceAngelo
Esri Esteemed Contributor

Be sure you read up on how Esri's versioning model operates.  There is no difference between the child and parent versions if no editing has occurred. The active version is a connnection property.

- V

JAY_PRAKASHKUMAR
New Contributor III

I have read the same and as you say active version is connection property but I am unable to get the path of the child version even I am trying to perform some operation let say arcpy.MakeFeatureLayer_management('path of child version feature class','any name for temporary new feature class')

I am getting an error

error 000732 does not exist or is not supported failed to execute

which clearly says I am unable to reach to my feature class for child version while the same operation happens when I give the path of default SDE version feature class [I just drag and drop in python Console of ArcMap, the feature class from SDE connection for a child and default version]

Is it a specific way to reach the path of child version?

Thank you for your time

0 Kudos
VinceAngelo
Esri Esteemed Contributor

You haven't provided enough useful information.  What is the name of your user?  What is the name of the version?  From which version was the new version created. What exact parameter did you change on the connection UI?

- V

0 Kudos
JAY_PRAKASHKUMAR
New Contributor III

Hello Vince,

It seems I got the solution. Whenever I am trying to change the version of SDE I should restart the ArcMap and then I was able to get the path of child version 

0 Kudos
VinceAngelo
Esri Esteemed Contributor

No, this is not part of the standard workflow.

- V

JAY_PRAKASHKUMAR
New Contributor III

Hi Vince,

I know that's not the standard workflow. Let me explain to you my problem. 

Let say I have many versions of particular SDE. Eg. Let say they are A,B,C, DEFAULT.

I dragged and dropped a particular feature class says MAIN from version DEFAULT.

   1. I started editing mode on.

   2. Selected some features in main

   3. Now trying to read path of the selected features in MAIN in the following pythonic way.

         mxd = arcpy.mapping.MapDocument("CURRENT")

         layer = arcpy.mapping.ListLayers(mxd)

         for i in layer:

             print arcpy.Describe(i).catalogPath

   This gives the result 

     Databaseconnection.sde\MAIN

4. Now I changed the version of the MAIN layer in TOC to let say Version A and applied the same above code to get the path of the Version A

 

This gives the result

   MAIN

Conclusion 

I am unable to fetch the exact path of the feature when trying to change the version in TOC from current version to some other version. This is halting me perform my other operations.

Can you kindly help me with getting the path of the feature class in a versioned SDE?

Thank you for your time

Jay Prakash Kumar

0 Kudos
JAY_PRAKASHKUMAR
New Contributor III

Hello Vince,

It was a bug that ESRI solved in 10.6

https://gis.stackexchange.com/questions/244925/arcpy-mapping-listlayers-returns-inconsistent-datasou...

But still, I am looking for some alternative. If you could give some workaround then that will be helpful

Thank you for your time

Jay

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

The only alternate solution was given in the bug

Right-click the database connection, select Geodatabase Connection Properties, and point to the right version
0 Kudos