Skip to main content
Question

Obtain path to database connection file using pythoncaller

  • April 9, 2024
  • 1 reply
  • 162 views

_jacques_
Supporter
Forum|alt.badge.img+14

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

_jacques_
Supporter
Forum|alt.badge.img+14
  • 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")

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings