get path of sde file

06-07-2017 06:55 AM
New Contributor II

Hello for all,
I have a problem and please help me.
I need to get path of sde file for enterprise geodatabase.

Up to 1.3 version for ArcGIS Pro, the Geodatabase class had GetPath() method which returned path for Geodatabase (File Geodatabase, Enterprise Geodatabase and so on) .

Starting with 1.4 version this method is depricated (and return empty string) and it's recomended to work with Conector and appropriate class (DatabaseConnectionFile, DatabaseConnectionProperties and so on)

I need to get path of sde file (Enterprise Geodatabase), but Connector is not DatabaseConnectionFile.
When Geodatabase is Enterprise, the Connector is only DatabaseConnectionProperties-type.
But DatabaseConnectionProperties does not allow to get path of sde file.

(_table.GetDatastore() as Geodatabase).GetConnector() is DatabaseConnectionFile is false

How can I get the path of sde file?

Thanks all,
Laurentiu Ichim

0 Kudos
14 Replies
Esri Regular Contributor


Situation with ArcGIS Pro SDK has changed since 2017.

We have used workaround with adding database to project Catalog-Databases. Then we checked database connection properties with all databases added to Catalog-Databases. On right one we used GDBProjectItem Path property to get right sde file path.

All registered to project databases you can get using code:

IEnumerable<GDBProjectItem> projectDatabases = Project.Current.GetItems<GDBProjectItem>();

We do not use this way now. We are trying to work without sde file path or save it to project as settings. 

The copy of sde file you can get by calling GetPath from Geodatabase object.

Could you explain why do you need right sde file path? Maybe I will suggest you a way how to avoid sde file path.

0 Kudos
Occasional Contributor

@GKmieliauskas I need to create a relationship class using the geoprocessing module since the ddl module can't do it. I need to let the tool know what the path to the relationship class is.

var tName = table.GetName();
var rlcName = $"{ValidateMemberName(tName)}_HTE";
var rlcpath = System.IO.Path.Combine(gdb.GetPath().LocalPath, rlcName);
var originTable = gdb.OpenDataset<Table>(tName);
var destTable = gdb.OpenDataset<Table>(etTableName);
var originPrimaryKey = originTable.GetDefinition().GetObjectIDField();
var k=Geoprocessing.ExecuteToolAsync("CreateRelationshipClass_management", Geoprocessing.MakeValueArray(originTable, destTable, rlcpath, "SIMPLE", ForwardPathLabel,
                    BackwardPathLabel, "NONE", "ONE_TO_MANY", "NONE", originPrimaryKey, originForeignKey));
0 Kudos
Esri Regular Contributor

Have you tried to execute CreateRelationshipClass tool from ArcGIS Pro? Run the tool then go to History and right click mouse on CreateRelationshipClass record and select Copy Python Command from context menu.

Paste content to Notepad and check Python script for relationship class path parameter.

0 Kudos
Occasional Contributor

@GKmieliauskas yes I have. It still shows me the temporary/local path of the sde file which won't work in the pro sdk.

0 Kudos
Esri Regular Contributor


It seems like a bug. I would recommend to start new thread in ArcGIS Pro SDK.  Maybe some from Esri could help you.