Skip to main content

Generate configuration files for martin vector tile server

Project description

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;

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

martin-config-0.1.3.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

martin_config-0.1.3-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file martin-config-0.1.3.tar.gz.

File metadata

  • Download URL: martin-config-0.1.3.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for martin-config-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4d8f1a8f1ab018df5728df89591a5774535827184c164a0e8f43ecadf7822f87
MD5 599961d68aee460728ed4310aa986cb1
BLAKE2b-256 3b4a97a5dd330f13f3af318be7b814360db46fdb08502190df7d49134731cc4a

See more details on using hashes here.

File details

Details for the file martin_config-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for martin_config-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 62bb1aef3995a0359f7116837eab960e153f5c18eb8cc1dc3d04bcb69f2ff9d9
MD5 736daf202853cdb660387c90887047f5
BLAKE2b-256 3d51ab21bc1901efaaa2e02264773bede56377773c188abd49bcf816e34137aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page