Select to view content in your preferred language

Use ArcPy to Determine Underlying Database

2040
7
08-28-2014 10:06 AM
Status: Implemented
Labels (2)
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


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

HannesZiegler
Status changed to: In Product Plan

We're working on this!  This status does not guarantee that the functionality will be in the next release, but development work has begun. Release cycles vary by product so make sure to check the product life cycle information to get an idea of when to expect the next release.  

KoryKramer
Status changed to: Implemented

This is implemented in ArcGIS Pro 3.3. See Your Ideas in ArcGIS Pro 3.3 for a full list of all user ideas you can look forward to! And be sure to check out the release blog and what’s new help topic and video to learn more about all the new features and functionality in the release.

philnagel

@HannesZiegler or @KoryKramer - could you elaborate on how this was implemented? I am not seeing this in the describe object still at 3.4 and don't see any mention of it in the linked release blog or help topic. Thanks!

HannesZiegler

@philnagel Apologies, we didn't cover this properly when we closed the idea, the underlying database can be identified using the dbClient property of connectionProperties when describing SDE workspaces: Workspace properties—ArcGIS Pro | Documentation

desc = arcpy.Describe("C:\\...\\mydb.sde")
print(desc.connectionProperties.dbClient)

Would return the one of the following for SDE workspaces:

FileGDB
Sqlite
sqlserver
oracle
postgresql

 

philnagel

@HannesZiegler Thank you - I do see those entries now in the docs. What threw me for a loop was that it does not get included when using arcpy.da.Describe. 

Any ideas on that? Is that a bug?

 

philnagel_0-1744220399814.png

 

HannesZiegler

Yea that is an issue, there is an idea for it here: arcpy.da.Describe should return the same data as a... - Esri Community

You can upvote (kudo) it, we keep tabs on ideas (this one is already under consideration)