Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 7 down vote accepted

I would try the Describe Workspace release property

http://resources.arcgis.com/en/help/main/10.1/index.html#/Workspace_properties/018v0000002v000000/

share|improve this answer
    
And if I'm using 10.0? –  ian Jan 31 '13 at 20:34
2  
@I-B, in your original question you did ask if you could also find out if a gdb was 10.1, so I think it was fair to assume you were using 10.1, as it's unlikely that previous version (ie: 10.0) would ever be able to tell you anything about a future version gdb. –  RyanDalton Jan 31 '13 at 22:14
    
From the linked help, it looks like there is no differentiation between 10.0 and 10.1 release geodatabases. Both will return the value 3,0,0. –  blah238 Jan 31 '13 at 23:17

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 :|

share|improve this answer
1  
Are you sure it is a 10.1 GeoDatabase and not just a 10.0 database that has been opened in 10.1? Can you use the "upgrade Geodatabase" button on it? help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… –  Ragi Yaser Burhum Jan 31 '13 at 22:54
    
It says it's at the current release on my 10.1 box and I cannot upgrade it. –  blah238 Jan 31 '13 at 23:00
1  
ArcGIS bug for sure :) –  Ragi Yaser Burhum Jan 31 '13 at 23:01
1  
Actually the 10.1 arcpy Workspace describe 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#/… –  blah238 Jan 31 '13 at 23:16
1  
All that code does is do a select() on one of the tables that has a string called version. That string gets updated whenever the GeoDatabase schema gets changed. It is very possible that the GeoDatabase schema was not changed for that release, and hence nobody touched the code and hence the value did not get touched. IMHO, it should get touched by every release, but I guess if the schema is the same it means it can be opened on both ArcGIS versions - so in reality there is no "10.1" GDB, just a 10.0 GDB. –  Ragi Yaser Burhum Feb 1 '13 at 0:12

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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.