I want to find out if either a file or personal geodatabase is 9.3, 10.0, 10.1, etc
Is there a way to do this using Python?
I want to find out if either a file or personal geodatabase is 9.3, 10.0, 10.1, etc
Is there a way to do this using Python?
I would try the Describe Workspace release property
http://resources.arcgis.com/en/help/main/10.1/index.html#/Workspace_properties/018v0000002v000000/
3,0,0
.
Here's an ArcObjects + comtypes solution that works for me at 10.0:
import arcpy
from ESRICOMHelpers import GetESRIModule, CType, NewObj
def GetGDBReleaseVersion(gdbPath):
"""Gets the release version of the given geodatabase."""
esriGeoDatabase = GetESRIModule("esriGeoDatabase")
esriGeoprocessing = GetESRIModule("esriGeoprocessing")
gpUtilities = NewObj(esriGeoprocessing.GPUtilities, esriGeoprocessing.IGPUtilities)
try:
dataset = gpUtilities.OpenDatasetFromLocation(gdbPath)
workspace = CType(dataset, esriGeoDatabase.IWorkspace)
gdbRelease = CType(workspace, esriGeoDatabase.IGeodatabaseRelease2)
return "%d.%d" % (gdbRelease.MajorVersion + 7, gdbRelease.MinorVersion)
except:
return None
if __name__ == "__main__":
print GetGDBReleaseVersion(r"C:\GISData\test.gdb")
Output:
>>> 10.0
Grab comtypes here and ESRICOMHelpers here. If you are at 10.1 be sure to tweak comtypes' automation.py
as described in this answer.
Note: Be warned that this also returns 10.0 for 10.1 geodatabases when run from ArcGIS 10.0! Edit: Actually this returns 10.0 for a 10.1 file geodatabase when run from ArcGIS 10.1 as well! Not sure what is going on :|
release
property returns the same for both 10.0 and 10.1 release geodatabases as well: resources.arcgis.com/en/help/main/10.1/index.html#/…
Good question! In 10.0, I cannot find any Python method for describing the version of the geodatabase. I've tested using the Upgrade geodatabase GP tool in 10.1 and it might be helpful.
"The Upgrade Geodatabase tool will only work against geodatabases that are at a previous release."
This means we can test running this tool without setting the option "Upgrade geodatabase" just to see if it will execute (if the geodatabase is of the same version it won't execute). If it will - then it is of current version (only the pre-requisites check will be performed and the geodatabase will be left untouched).
Regarding testing 9.3 and 10.1 - I was thinking of trying to create a sample dataset that is possible to create only in geodatabase of version 10.0 / 10.1 and then check if it gets created. If not - then it is 9.3 / 10.1.
Not the most elegant solution though...