Databases (ixmp4.db)

Module contents

This module is responsible for everything database related. Interfacing, migrating and more is all done here.

It uses sqlalchemy and alembic for database management.

Migrations

There is a development database at run/db.sqlite which is used for generating migrations, nothing else. It can be manipulated with alembic directly using these commands:

# run all migrations until the current state is reached
alembic upgrade head

# run one migration forward
alembic upgrade +1

# run one migration backward
alembic downgrade -1

# autogenerate new migration (please choose a descriptive change message)
alembic revision -m "<message>" --autogenerate

You will have to run all migrations before being able to create new ones in the development database. Be sure to run ruff on newly created migrations before committing them!

Subpackages

Submodules

ixmp4.db.filters module

ixmp4.db.filters.BaseFilter

alias of BaseFilter

class ixmp4.db.filters.FilterMeta(name: str, bases: tuple, namespace: dict, **kwargs)

Bases: ModelMetaclass

classmethod build_lookups(field_type: type) dict
classmethod expand_lookups(name: str, lookups: dict, namespace: dict, base_field_alias: str | None = None)
classmethod process_field(namespace: dict, field_name: str, field_type: type)
class ixmp4.db.filters.Float(x=0, /)

Bases: float

An explicit proxy type for float.

class ixmp4.db.filters.Id

Bases: int

A no-op type for a reduced set of Integer lookups.

class ixmp4.db.filters.Integer

Bases: int

An explicit proxy type for int.

class ixmp4.db.filters.String

Bases: str

An explicit proxy type for str.

ixmp4.db.filters.escape_wildcard(v)
ixmp4.db.filters.exact(c, v)
ixmp4.db.filters.expand_simple_filter(value)
ixmp4.db.filters.get_filter_func_name(n: str) str
ixmp4.db.filters.gt(c, v)
ixmp4.db.filters.gte(c, v)
ixmp4.db.filters.ilike(c, v)
ixmp4.db.filters.in_(c, v)
ixmp4.db.filters.like(c, v)
ixmp4.db.filters.lt(c, v)
ixmp4.db.filters.lte(c, v)
ixmp4.db.filters.notilike(c, v)
ixmp4.db.filters.notlike(c, v)