Skip to main content
Question

Obtain path to database connection file using pythoncaller

  • April 9, 2024
  • 3 replies
  • 263 views

_jacques_
Supporter
Forum|alt.badge.img+19

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 👷🏼

 

3 replies

_jacques_
Supporter
Forum|alt.badge.img+19
  • Author
  • Supporter
  • April 10, 2024

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")

 


nic_ran
Contributor
Forum|alt.badge.img+16
  • Contributor
  • November 25, 2025

Amazing! I didn’t even know this API existed. Thanks for sharing.


_jacques_
Supporter
Forum|alt.badge.img+19
  • Author
  • Supporter
  • November 26, 2025

Amazing! I didn’t even know this API existed. Thanks for sharing.

There are a lot of useful functions “hidden” in the API documentation.
Python FME API documentation — Python FME API FME 2025.1 b25615 documentation