To test it I set the connection file as a workspace and ran arcpy.ListFeatureClasses() against it. It did not raise any errors, but it also did not return any featureclasses that are in SDE.
import arcpy sdeConn = r"<connection file>" ##this is the one that was created with arcpy.management.CreateDatabaseConnection arcpy.env.workspace = sdeConn for fc in arcpy.ListFeatureClasses(): print fc
The code was just something benign like this. I run it from IDLE and it completes without raising an error, but also without printing any featureclass names.import arcpy sdeConn = r"<connection file>" ##this is the one that was created with arcpy.management.CreateDatabaseConnection arcpy.env.workspace = sdeConn for fc in arcpy.ListFeatureClasses(): print fc
In the absence of try/except IDLE should raise any error.
sdeFC = r"<remote db server>\SDE_Connection.sde"
I am unfamiliar with attempting to access items from a particular schema like you are "DB.sde\DB.dbo.FeatureClass". Have you tried to ListFeatureClasses() with just the .sde connection alone?
What you reference was just an example of accessing a FeatureClass directly, just as you would from a FGDB, i.e. C:\FGDB.gdb\FeatureClass. When you do the same thing in SDE the path includes the DB connection file + the DB + the schema + the featureclass name.
But that is all really irrelevant.
I'm just trying to find a way to have python on one cloud server access an SDE instance on another cloud server, presumably using a connection file I can create on the non-SDE server.
I created a connection file like this and tested it. It worked in the sense that it did not raise an error, but it also did not give me the result I was expecting.
sdeFC = r"<remote db server>\SDE_Connection.sde" for fc in arcpy.ListFeatureClasses(): print fc
sdeFC = r"<remote db server>\SDE_Connection.sde\DB.dbo.FeatureClass" for fc in arcpy.ListFeatureClasses(): print fc
Do this:sdeFC = r"<remote db server>\SDE_Connection.sde" for fc in arcpy.ListFeatureClasses(): print fc
The script would surely error out if I tried to read featureclasses from something that is not a workspace.