Skip to content

openknowledge-archive/datapackage-sql-py

Repository files navigation

datapackage-sql-py

Travis Coveralls

Generate and load SQL tables based on Data Package.

Usage

This section is intended to be used by end-users of the library.

Import/Export

See section below how to get tabular storage object.

High-level API is easy to use.

Having Data Package in current directory we can import it to sql database:

import dpsql

dpsql.import_package(<storage>, 'descriptor.json')

Also we can export it from sql database:

import dpsql

dpsql.export_package(<storage>, 'descriptor.json', 'datapackage_name')

Tabular Storage

SQLAlchemy is used as sql wrapper. We can get storage this way:

import jtssql
from sqlalchemy import create_engine

engine = create_engine('sqlite:///:memory:')
storage = jtssql.Storage(engine)

Design Overview

Storage & Drivers

See jsontableschema layer readme.

Mappings

datapackage.json -> *not stored*
datapackage.json resources -> sql  tables
data/data.csv schema -> sql table schema
data/data.csv data -> sql table data

Development

This section is intended to be used by tech users collaborating on this project.

Getting Started

To activate virtual environment, install dependencies, add pre-commit hook to review and test code and get run command as unified developer interface:

$ source activate.sh

Reviewing

The project follow the next style guides:

To check the project against Python style guide:

$ run review

Testing

To run tests with coverage check:

$ run test

Coverage data will be in the .coverage file.