opengisch / QFieldCloud

QFieldCloud allows seamless synchronization of your field data with your spatial infrastructure with change tracking, team management and online-offline work capabilities in QField.
https://qfield.cloud
MIT License
114 stars 51 forks source link

Can't connect QFieldCloud to PostGIS #957

Closed sigsdis30 closed 3 months ago

sigsdis30 commented 3 months ago

Hello,

We have installed QFieldCloud v0.26.5 on our own server. The synchronization of projects with geopackages works well. However, we would like to create a project that uses layers from a PostGIS database to update the layers directly in the database.

We noticed that QFieldCloud uses secrets for connecting to a PostGIS database. However, we don't see an option to configure these secrets in the admin interface.

We read in this discussion (https://github.com/opengisch/QField/discussions/4771) that the secrets are not yet accessible from the interface. To connect QFieldCloud to PostGIS, should we revert to an older version? If so, which version would you recommend and is it available? When do you think this feature will be available in the interface? Can the QFieldCloud SDK help to work around this issue?

Thank you for your assistance.

boardend commented 3 months ago

Hi @sigsdis30

Note that secrets can now be added/modified through the admin panel with QFieldCloud version >= 0.27.0

rom2049 commented 3 months ago

Thank @boardend for your response

There is indeed the possibility to add secrets in the interface with v0.27.0. However, the update in PostGIS is not occurring, and I notice that the 'Value' field of the secrets always remains empty after creation or modification.

joostvenema commented 3 months ago

Hi, we're struggling with the exact same situation. Any directions how to solve this are very welcome.

boardend commented 3 months ago

That the value remains empty is intended. One can only add and overwrite secrets, but not retrieve the actual secret value via the admin.

For adding a PostGIS database, you have to add a secret with the type pg_service. Note that there is no fancy editor in the the admin panel. Create a ~/.pg_service.conf locally and verify the connection. Or use the editor on https://app.qfield.cloud and copy the value from the "Advanced editor" into the admin panel (see also https://docs.qfield.org/reference/qfieldcloud/secrets/ )

With this in place, you should be able to add a PostGIS database as described here: https://docs.qfield.org/get-started/tutorials/advanced-setup-qfc/#postgis

sigsdis30 commented 3 months ago

@joostvenema The synchronization with Postgres is now working. To do this, I need to start with an empty QField project by selecting "create a new empty QFieldCloud project." This discussion helped me: https://github.com/opengisch/QField/discussions/2508

joostvenema commented 3 months ago

@boardend, @sigsdis30,

Thanks for your comments! We managed to get it to work. Also this documentation helped to understand the configuration of the database on the QGIS side: https://docs.qfield.org/how-to/pg-service/?h=connection#creating-a-pg_serviceconf-file-for-postgresql-connection-in-qgis-and-secrets

boardend commented 3 months ago

Thanks for the feedback :+1: