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.17.1.tar.gz (59.2 kB view details)

Uploaded Source

Built Distribution

amsterdam_schema_tools-0.17.1-py3-none-any.whl (84.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: amsterdam-schema-tools-0.17.1.tar.gz
  • Upload date:
  • Size: 59.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for amsterdam-schema-tools-0.17.1.tar.gz
Algorithm Hash digest
SHA256 c3692223c434debad5810a9b766d089448bdbf14b105fb8bb409292f895642c5
MD5 e37a1ded291f331a2e8c0a6febefce85
BLAKE2b-256 e3e508fdc80d3320138faa204f1cf0a08e2b8cfb6b2630d2aac2cb2bd3e5fbe0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: amsterdam_schema_tools-0.17.1-py3-none-any.whl
  • Upload date:
  • Size: 84.1 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.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2efb97fed0fb80808657587a1b0940aa1b9036b7b4b30363219e32fd2a4dbdb8
MD5 8753b2b8780b7546a623cb0e9392b012
BLAKE2b-256 127e9bc38d3e2a8eeeb8c5711620393f798c1120d7f73dacc2342fa7084f7447

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