Coverage for gws-app/gws/plugin/postgres/__init__.py: 100%
0 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""PostgreSQL/PostGIS support.
3Provides a database provider for PostgreSQL and the objects that use it:
4layers, models, finders, an authorization provider and a storage provider.
5The database-independent parts are in ``gws.base.database``; this plugin adds
6the PostgreSQL specifics.
8Submodules:
10- ``provider``: the ``postgres`` database provider. Builds the connection URL
11 from host and credentials or from a service name in the PostgreSQL service
12 file, splits and joins schema-qualified table names (the default schema is
13 ``public``; quoted identifiers are supported), computes table bounds with
14 ``ST_Extent`` and detects array columns (described as ``strlist``,
15 ``intlist`` or ``floatlist`` when the item type is known) and the geometry
16 type and SRID of PostGIS columns, also for constraint-based geometry columns
17 without a type modifier, via ``public.geometry_columns``.
18- ``layer``: the ``postgres`` vector layer that shows the features of a table.
19- ``model``: the ``postgres`` model that reads and writes the records of a table.
20- ``finder``: the ``postgres`` finder that searches a table by keyword,
21 geometry and filter. The search itself is done by the ``postgres`` models of
22 the finder; all three search types are always enabled, since the actual
23 support depends on the models.
24- ``auth_provider``: the ``postgres`` authorization provider that checks
25 credentials and loads users with SQL queries.
26- ``storage_provider``: the ``postgres`` storage provider that keeps saved
27 user data in a table. The table is not created by the provider; writing a
28 record with an existing category and name replaces it.
30Objects find their database provider by ``dbUid``. Without ``dbUid``, the
31first configured ``postgres`` provider is used.
33Example::
35 database.providers+ {
36 uid "main_db"
37 type "postgres"
38 serviceName "LOCAL"
39 }
41 map.layers+ {
42 title "POIs"
43 type "postgres"
44 dbUid "main_db"
45 tableName "edit.poi"
46 }
48 storage.providers+ {
49 type "postgres"
50 dbUid "main_db"
51 tableName "public.gws_storage"
52 }
53"""