Skip to main content

Tools to work with Amsterdam schema.

Project description

amsterdam-schema-tools

Set of libraries and tools to work with Amsterdam schema.

Install the package with: pip install amsterdam-schema-tools

Currently, the following cli commands are available:

  • schema import events
  • schema import ndjson
  • schema show schema
  • schema show tablenames
  • schema introspect db
  • schema introspect geojson *.geojson
  • schema validate
  • schema permissions apply

The tools expect either a DATABASE_URL environment variable or a command-line option --db-url with a DSN.

The output is a json-schema output according to the Amsterdam schemas definition for the tables that are being processed.

Generate amsterdam schema from existing database tables

The --prefix argument controls whether table prefixes are removed in the schema, because that is required for Django models.

As example we can generate a BAG schema. Point DATABASE_URL to bag_v11 database and then run :

schema show tablenames | sort | awk '/^bag_/{print}' | xargs schema introspect db bag --prefix bag_ | jq

The jq formats it nicely and it can be redirected to the correct directory in the schemas repository directly.

Express amsterdam schema information in relational tables

Amsterdam schema is expressed as jsonschema. However, to make it easier for people with a more relational mind- or toolset it is possible to express amsterdam schema as a set of relational tables. These tables are meta_dataset, meta_table and meta_field.

It is possible to convert a jsonschema into the relational table structure and vice-versa.

This command converts a dataset from an existing dataset in jsonschema format:

schema import schema <id of dataset>

To convert from relational tables back to jsonschema:

schema show schema <id of dataset>

Generating amsterdam schema from existing GeoJSON files

The following command can be used to inspect and import the GeoJSON files:

schema introspect geojson <dataset-id> *.geojson > schema.json
edit schema.json  # fine-tune the table names
schema import geojson schema.json <table1> file1.geojson
schema import geojson schema.json <table2> file2.geojson

Importing GOB events

The schematools library has a module that read GOB events into database tables that are defines by an Amsterdam schema. This module can be used to read GOB events from a Kafka stream. It is also possible to read GOB events from a batch file with line-separeted events using:

schema import events <path-to-dataset> <path-to-file-with-events>

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

amsterdam-schema-tools-0.18.2.tar.gz (62.7 kB view details)

Uploaded Source

Built Distributions

amsterdam_schema_tools-0.18.2-py3-none-any.whl (91.7 kB view details)

Uploaded Python 3

amsterdam_schema_tools-0.18.2-py2.py3-none-any.whl (85.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file amsterdam-schema-tools-0.18.2.tar.gz.

File metadata

  • Download URL: amsterdam-schema-tools-0.18.2.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for amsterdam-schema-tools-0.18.2.tar.gz
Algorithm Hash digest
SHA256 b47031740a543581ff16db9466d5da29d78a2589a9aa6023efbbe3abd8886447
MD5 c684bedb1f1a036e1cce5a0dcad9f9dd
BLAKE2b-256 a643d8e632b63c7782e4346afca81ad7d639d5ce8961e64dc29e6647df536a94

See more details on using hashes here.

File details

Details for the file amsterdam_schema_tools-0.18.2-py3-none-any.whl.

File metadata

  • Download URL: amsterdam_schema_tools-0.18.2-py3-none-any.whl
  • Upload date:
  • Size: 91.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for amsterdam_schema_tools-0.18.2-py3-none-any.whl
Algorithm Hash digest
SHA256 418fe8b2cdce40962e2be1d0909ae6c1dbba7a70a33769f5a92edc4a86a07458
MD5 d11db8580a22dc89f4056bae42650ebd
BLAKE2b-256 63b1731a86b1b4569c1164eb0d5967b8676b21ff60b4669d019e2001deabfb85

See more details on using hashes here.

File details

Details for the file amsterdam_schema_tools-0.18.2-py2.py3-none-any.whl.

File metadata

  • Download URL: amsterdam_schema_tools-0.18.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 85.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for amsterdam_schema_tools-0.18.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d699547457f4014a7a344b907f128303a661fa406a974b5b8bfd0bfc14a065ae
MD5 496ec93519920cb5174263b872761b42
BLAKE2b-256 95d85e333879b758a56a5dc152d3056fe63ce6791f36ba57d61b4c2577364511

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