Skip to main content

martin-config

A python tool to generate config.yaml for martin vector tiles server from PostGIS database leveraging asyncpg library.
martin server uses a YAML config file to specify what tables/functions from the PostGIS DB will be published.

##Features


martin-config uses asyncpg to interact with the Postgres server and supports following functionality:

  • creating config for table sources
  • creating config for function sources
  • creating config for the general section
  • operate in one, multiple or all schemas
  • selective publishing of tables through table comments
  • selective publishing of columns through column comments
  • uploading the config file to an Azure File Share using SAS authentication

Its strongest feature is the ability to select only the mark tables and table columns. This is achieved by inserting the

publish=True/False.

into the comment of a given table/column. The folowing rules apply

  • if a table does not have this string in the comments it is considered unmarked and unpublishable
  • if a has this string in comments its value dictates if the table is publishable (True) or unpublishable (False)
  • same logic applied to columns with the difference that unmarked columns are publishable by default

This allows users to mark/set the tables/columns selectively and use martin-config to generate a conforming config file.

Requirements


asyncpg, yaml, dotenv and optionally azure-file-share

Install


  1. Create a pipenv based venv
python3 -m pip install pipenv
pipenv --python 3
  1. install martin-config
pipenv run pip install martin-config
  1. optionally install azure functionality to be able to upload the cfg to AFS
pipenv run pip install martin-config[azure]

Usage


the installer creates a command line script martincfg

with pipenv it can be invoked like this:

pipenv run martincfg
pipenv run martincfg
Loading .env environment variables...
usage: martincfg [-h] [-s DATABASE_SCHEMA [DATABASE_SCHEMA ...]] [-o OUT_CFG_FILE] [-e ENV_FILE] [-d] [-sfs]

Create a config file for martin vector tile server

optional arguments:
  -h, --help            show this help message and exit
  -s DATABASE_SCHEMA [DATABASE_SCHEMA ...], --database-schema DATABASE_SCHEMA [DATABASE_SCHEMA ...]
                        A list of schema names. If no schema is specified all schemas are used.
  -o OUT_CFG_FILE, --out-cfg-file OUT_CFG_FILE
                        Full path to the config file to be created. If not supplied the YAML fill be dumped to stdout
  -e ENV_FILE, --env-file ENV_FILE
                        Load environmental variables from .env file
  -d, --debug           Set log level to debug
  -sfs, --skip-function-sources
                        Do not create config for function sources

Environmental variables

The arguments are self-explanatory. However, environmental variables are also required to be available at runtime, specifically:

 POSTGRES_DSN=postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
 
 AZURE_FILESHARE_SASURL=https://[storageaccount].file.core.windows.net/[sharename]?[SAS_QUERY_STRING]

Tips:

  • If no schema is specified all schemas are used.
  • multiple schemas can be specified one after another public myschema or public,myschema
  • .env file containing the above environmental variable can be used to the same effect as defining env. variables

For improving the performance of the script, please create statistics for all tables by the following SQL.

-- analyze all tables
ANALYZE;

-- analyze specific table
ANALYZE schema.tablename;

Metadata

Release files for martin-config 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for martin-config 0.1.3
File Size Uploaded
martin-config-0.1.3.tar.gz 16.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for martin-config 0.1.3
File Interpreter ABI Platform
martin_config-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / martin-config-0.1.3.tar.gz

Download URL martin-config-0.1.3.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4d8f1a8f1ab018df5728df89591a5774535827184c164a0e8f43ecadf7822f87
BLAKE2b-256 checksum
How to use checksums
3b4a97a5dd330f13f3af318be7b814360db46fdb08502190df7d49134731cc4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / martin_config-0.1.3-py3-none-any.whl

Download URL martin_config-0.1.3-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62bb1aef3995a0359f7116837eab960e153f5c18eb8cc1dc3d04bcb69f2ff9d9
BLAKE2b-256 checksum
How to use checksums
3d51ab21bc1901efaaa2e02264773bede56377773c188abd49bcf816e34137aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page