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 schema
  • schema import ndjson
  • schema show schema
  • schema show tablenames
  • schema introspect db
  • schema introspect geojson *.geojson
  • schema validate

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

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

Uploaded Source

Built Distribution

amsterdam_schema_tools-0.8.13-py2-none-any.whl (50.2 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: amsterdam-schema-tools-0.8.13.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for amsterdam-schema-tools-0.8.13.tar.gz
Algorithm Hash digest
SHA256 641ed01e5f506be55fcb4996231791b390f7c6689fb1a5ff8345caa3ce4b1443
MD5 65a48461b1b9156720c8f3832d3f0ee7
BLAKE2b-256 09e679e147f5e57e2c2705bab85ed1766cd93e1e713b983224d2b91c41058d6d

See more details on using hashes here.

File details

Details for the file amsterdam_schema_tools-0.8.13-py2-none-any.whl.

File metadata

  • Download URL: amsterdam_schema_tools-0.8.13-py2-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for amsterdam_schema_tools-0.8.13-py2-none-any.whl
Algorithm Hash digest
SHA256 662afa40c6dce2f1b1a2b030f3a969592aa4a489f6946084a4900d2bd6cf820a
MD5 978baabd3218e1e5e6ab2732866260b9
BLAKE2b-256 9a2c0603024a2b8e1096e5ffc63239d12e2750b9ff547bc296f29744bebf63c7

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