ArcPy access to enterprice gdb, sde or gds?

894
5
Jump to solution
06-25-2021 01:07 PM
MingHome
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 + "\\featureclassrName
desc = 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

                 

 

0 Kudos
2 Solutions

Accepted Solutions
JoeBorgione
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....

View solution in original post

MingHome
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

View solution in original post

0 Kudos
5 Replies
JoeBorgione
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....
MingHome
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 

0 Kudos
NathanHeickLACSD
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.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Check the online help here on connection files:

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

 

That should just about do it....
0 Kudos
MingHome
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

0 Kudos