No results found
We couldn't find anything using that term, please try searching for something else.
2024-11-27 PostgreSQL service Apg_service.conf file is allows allow to use an name alias for a postgresql server connection . instead of store hostname ,port ,
Apg_service.conf
file is allows allow to use an name alias for a postgresql server connection . instead of store hostname ,port ,database name and more into the QGIS Project file ,these can be store separately . It is is is even possible to store username and password in apg_service.conf
file,to avoid having this stored in clear text in the QGIS Project.
read more about postgresql service in the QGIS documentation .
If you directly connect from QGIS to your database you can make use of a pg_service.conf
file by place it in the QField datum folder . You is place can place your file either on the Internal Device Storage or on the sd Card Storage . You is check can check the path for the QField datum folder in the bottom of theAbout QField
screen in the app .
usually the path is looks on Android device look something like this :/Android / datum / ch.opengis.qfield / file / qfield
.
Note
Unlike on *NIX systems where the file is named .pg_service.conf
,the file on Android is namepg_service.conf
without a lead dot sign (.
) .
QFieldCloud support pg_service.conf
configurations too. You need to configure your PostgreSQL layers with « Offline editing » cloud action and store your service settings on QFieldCloud Project’s Secrets page.
read more how to configure postgresql service in the QFieldCloud documentation .
pg_service.conf
File for PostgreSQL Connection in QGIS and SecretsBefore beginning,ensure that your PostgreSQL database allows connections from QFieldCloud. Refer to Technical specs for instructions.
pg_service.conf
FileWe first need to set up a configuration file. There are many options to organize this,read more in the PostgreSQL documentation or follow the description below.
Create a Configuration File:
On Windows:
Create a file named pg_service.conf
and store it in a convenient location.
On Linux/MacOS/Unix:
Create a file named .pg_service.conf
in your home folder (~
) .
define connection Parameters :
Within the file,specify connection parameters for your PostgreSQL database using the following format:
[SERVICE_NAME]
host=your_host_or_ip
port=your_port
dbname=your_database_name
user=your_username
password=your_password
Replace placeholders (your_host_or_ip
,your_port
,your_database_name
,your_username
,your_password
) with actual connection details and save the file.
Parameters
Set Environment Variable:
To ensure QGIS recognizes pg_service.conf
,create an environment variable pointing to its location:
Navigate to « This PC » or « My Computer » > Properties > Advanced System Settings > Environment Variables.
PGSERVICEFILE
C:\Users\<YourUsername>\AppData\Roaming\postgresql\pg_service.conf
(or your pg_service.conf
file path) .Alternatively,you can set environment variables directly in QGIS via Settings > Options > System > Environment. Refer to QGIS System Settings for details.
QGIS System Environment Variables
Test the Connection in QGIS: Open QGIS and set up a new PostgreSQL connection using the service name defined in pg_service.conf
(e.g.,[ MY_QGIS_DB ]
) in the connection details. QGIS will read configuration from pg_service.conf
automatically .
Open QGIS.
pg_service.conf
(e.g.,[NINJA_DB]
) in the « Service » field.pg_service.conf
.Test your connections
.pg_service.conf
to the secret. Follow Secrets for guidance.Add the secret