Skip to content

📦 Import Frictionless Data Datapackages into SQLite and generate Datasette metadata

License

Notifications You must be signed in to change notification settings

chris48s/datapackage-to-datasette

Repository files navigation

datapackage-to-datasette

Run tests codecov PyPI Version License Python Compatibility Code style: black

Import Frictionless Data Datapackages into SQLite and generate Datasette metadata.

Setup

pip install datapackage-to-datasette

Usage

On the console

Import a datapackage from a local file

datapackage-to-datasette mydatabase.db /path/to/datapackage.json metadata.json

or from a URL

datapackage-to-datasette mydatabase.db https://pkgstore.datahub.io/core/co2-ppm/10/datapackage.json metadata.json

If the datasette metadata file already exists, you can pass --write-mode replace or --write-mode merge to overwrite or merge with the existing datasette metadata file.

As a library

from datapackage_to_datasette import datapackage_to_datasette, DataImportError

try:
    datapackage_to_datasette(
        'mydatabase.db',
        '/path/to/datapackage.json',
        'metadata.json',
        write_mode='replace'
    )
except DataImportError:
    raise