Question

Obtain path to database connection file using pythoncaller

  • 9 April 2024
  • 1 reply
  • 30 views

Badge +1

Hi, 

I’m working on a script which copies data from an Esri arcsde geodatabase to a postgis database. I need to know if the table in the arcsde geodatabase is versioned before I run the rest of the script, and I have a pythoncaller which runs something like this (simplified here):

layername = "schema.layerName"
connectionFile = "path_to_connection_file"
arcpy.env.workspace = connectionFile

desc = arcpy.Describe(layername)
isVer = desc.isversioned

feature.setAttribute("versioned",isVer)
self.pyoutput(feature)

Now, I don’t want to type in the path to the connection file manually, but rather obtain it by some function which can collect the data from the list of database connections I entered in the settings.

 

Is this possible? I’ve looked into the FME Web Services API reference for such a function without any luck.

 

Best regards,

Jacques 👷🏼

 


1 reply

Badge +1

Found it, here’s for anyone looking for the answer:

 

import fmewebservices

ncm = fmewebservices.FMENamedConnectionManager()
connection = ncm.getNamedConnection("connection_name")
connection_file_path = connection.getNameValues().get("DATASET")

 

Reply