Select to view content in your preferred language

Is there a TNS-similar way to connect to Postgres database from ArcGIS PRO?

899
0
09-18-2023 06:20 AM
Labels (2)
AndersMark
Emerging Contributor

When using Oracle you can use TNS and create a generic name for a datasource. This name can then be used from ArcGIS Database connection. That means that the exact same service can be published on several Arcgis servers and by configuration use different databases.

There seems to be a similar way of doing this in Postgres called something like PGSERVICE. A layer between the caller (psql, Arcgis) and the actual server and database. 

I have made a few tests and got this to work when using Postgres sql tool, called psql. Now the question is: How do I make a connection from ArcGIS and use the configuration in PGSERVICEFILE ?

 

Example:

I have a Postgres database set up on another machine. From ArcGIS PRO I want to connect to that database by using definitions in the connection service file (https://www.postgresql.org/docs/current/libpq-pgservice.html)

If we take the example from page above I would like to make a database connection i AGP that uses the [mydb] entry. 

[mydb]
host=somehost
port=5433
user=someuser
password=somepassword

I have made adjustments in my local service file and can verify that it works by making a call to"psql", e.g:

"C:\Program Files\PostgreSQL\14\bin\psql.exe" -d service=mydb

This login works perfect. Now I want to use "mydb" from database connections but cant figure out the syntax. Anyone who has tried this?

What I would like to recreate here is the same behaviour as you can with Oracle and where you can make a database connection and just use the TNS-names. 

 

0 Kudos
0 Replies