Arkindex Export

Easily build queries for Arkindex SQLite exports

Installation

This library is available on PyPI.

You can install it easily with pip:

pip install arkindex-export

Usage

The only requirement is to have an Arkindex export database. The Arkindex documentation includes how to obtain one and what it contains.

This Python package offers up-to-date Peewee models to build queries against the database through the ORM, instead of writing raw SQL.

Example

from arkindex_export import open_database, Element
from pathlib import Path

# Setup usage for your database
db_path = Path("path/to/db.sqlite")
open_database(db_path)

# You can then query the models!
for e in Element.select().order_by('name'):
   print(e.id, e.name)

Upgrade the version of an existing export

If you have an older version of the export, a script may help you update it directly. These scripts are located in the upgrades folder of the Git repository. They must exactly match the existing export version, please use them carefully. We strongly recommend backing up the database before migrating it!

Example usage:

sqlite3 -bail export_version_10.sqlite < upgrades/10_to_11.sql

Development

For development and tests purpose it may be useful to install the project as an editable package with pip.

  • Use a virtualenv (e.g. with virtualenvwrapper mkvirtualenv -a . export)

  • Install export as a package (e.g. pip install -e .)

Linter

Code syntax is analyzed before submitting the code. To run the linter tools suite you may use pre-commit.

pip install pre-commit
pre-commit run -a

Run tests

Tests are executed with tox using pytest.

pip install tox
tox

To reload the test virtual environment you can use tox -r

Run a single test module: tox — <test_path>

Run a single test: tox — <test_path>::<test_function>