Use ArcPy to Determine Underlying Database

786
2
08-28-2014 10:06 AM
Status: Closed
AndrewChapkowski
Esri Regular Contributor
It would be nice if the arcpy Describe function would return the database name you are connected to.  

For example:
>>> print arcpy.Describe(r"c:\temp\scratch.gdb").databaseName
File Geodatabase
>>> print arcpy.Describe(r"c:\temp\someconnection.sde").databaseName
Oracle
>>> print arcpy.Describe(r"c:\temp\someconnection.sde").databaseName
PostGRESql

etc...

This would really help in developing the slight SQL differences between databases in handling of specific datatypes.

Thank you


2 Comments
MatthewYager

For your examples you could craft a routine to tell you this information
anything ending in a gdb will be file geodatabase
do a describe on a sde connection and look at the instance will tell you that database it is based on the connection string  e.g.

  • sde:sqlserver:svr-gis-01  is SQL server
  • sde:oracle11g:GISDATA  is Oracle 11g 
desc = arcpy.Describe(Database Connections\Localhost SQL.sde)
cp = desc.connectionProperties
print cp.instance
> sde:sqlserver:svr-gis-01

The only issue I see are the old style SDE connection where the instance will be a port number.

MaggieBusek
Status changed to: Closed