894
5
06-25-2021 01:07 PM
by
New Contributor III

Dear all,

I have question regarding using arcpy to access to enterprice geodatabase. According to my research, the enterprice gdb is defined with a sde file on harddrive and I can just use the filepath of this sde as the workspace to access to this gdb. I have been doing this for a number of sql gdb and it works fine for me. The steps are as followings:

1. Create/define a Database Connection in ArcCatelog, this will create a sde file
2. Using the filepath of sde file for the workspace for arcpy code. For example:
ws = "C:\\Users\\user\\AppData\\Roaming\\ESRI\\Desktop10.8\\ArcCatalog\\myGDB.sde"layerPath = ws + "\\featureclassrNamedesc = arcpy.dDescribe(layerPath)gdb_df = pd.DataFrame.spatial.from_featureclass(layerPath)

However, I encountered an Enterprice gdb server that is not defined with sde, rather, it is defined with gds. For example, "C:\\Users\\user\\AppData\\Roaming\\ESRI\\Desktop10.8\\ArcCatalog\\myGDB.gds". If I use this file path for ArcPy, it will return "Cannot open file" msg.

So, my question is, how to access Enterprice Geodatabase Server define with *.gds file? Do I have to created Database Connection in ArcCatelog instead of Database Server?

Thanks a lot and have a nice weekend!

Ming

2 Solutions

Accepted Solutions
MVP Esteemed Contributor

In the realm of ArcGIS, connecting to a 'Server' in catalog or Pro means connecting to an ArcGIS Server which is considered part of an enterprise.  SDE is actually an outdated term as it has been replaced with Enterprise Geodatabase (EGDB).

If you are connecting to an EGDB, I suggest creating a connection file. Keep it somewhere and always refer to that path and file name in python.

import arcpy
arcpy.env.workspace = r'DriveLetter:\path\to\your\ConnectionFile.sde'
ws = arcpy.env.workspace
fc = f'{ws}\yourFeatureClassName'
That should just about do it....
by
New Contributor III

Thanks to Joe and Nathan!

It seam that ArcPy access to EGDB via Database Connection (SDE file). Therefore, a connectionFile.sde has to be made either with ArcCatelog, or ArcTool, or command:

CreateArcSDEConnectionFile()

Thanks!

Ming

5 Replies
MVP Esteemed Contributor

In the realm of ArcGIS, connecting to a 'Server' in catalog or Pro means connecting to an ArcGIS Server which is considered part of an enterprise.  SDE is actually an outdated term as it has been replaced with Enterprise Geodatabase (EGDB).

If you are connecting to an EGDB, I suggest creating a connection file. Keep it somewhere and always refer to that path and file name in python.

import arcpy
arcpy.env.workspace = r'DriveLetter:\path\to\your\ConnectionFile.sde'
ws = arcpy.env.workspace
fc = f'{ws}\yourFeatureClassName'
That should just about do it....
by
New Contributor III

Thanks Joe for your prompt reply! I will give a try next week.

Regarding "creating a connection file", do you mean create a database connection in ArcCatelog (this will create a connection.sde file), or, write a sde file by my self. If the later, can you share a link about how or a sample?

Ming

Occasional Contributor III

Hi Ming, I'm not very familiar with this subject, but apparently .gds files are used to store connection information to database servers.  Check out the documentation here:

https://desktop.arcgis.com/en/arcmap/latest/manage-data/database-servers/overview-database-servers.h...

My first recommendation would be to try to open it in ArcCatalog.  It probably behaves just like an .sde connection.

MVP Esteemed Contributor

https://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/create-arcsde-connection-f...

That should just about do it....
by
New Contributor III

Thanks to Joe and Nathan!

It seam that ArcPy access to EGDB via Database Connection (SDE file). Therefore, a connectionFile.sde has to be made either with ArcCatelog, or ArcTool, or command:

CreateArcSDEConnectionFile()

Thanks!

Ming