[GIS] Reading ArcSDE data of a specific version in Python

arcpyenterprise-geodatabaseversioning

How can I read a version within Python?

For example, let's say I set up a workspace which points to a .SDE file connection. Now how can I read the features from a version within Python? I have looked online but can't find anything. Ideally if there is a code that looks for the version that is currently active and in use within the mxd?

Best Answer

arcpy.env.workspace = r'Database Connections\adminCon.sde'
arcpy.MakeFeatureLayer_management(r'Database Connections\adminCon.sde\GISADMIN.Buildings', 'fl')
arcpy.ChangeVersion_management('fl', "TRANSACTIONAL", "GISADMIN.Oli")
arcpy.ChangeVersion_management('fl', "TRANSACTIONAL", "sde.DEFAULT")

For further information check:

How to get a search cursor on a particular version in arcpy

Related Question