Files
zeekay dda3979851 rename: the ORM is ours — datastore_orm, not infi.clickhouse_orm
This is our fork, so it should read like it. `import datastore_orm` instead of
`from infi.clickhouse_orm import ...`: `infi` was the original vendor's org
namespace, and carrying someone else's org name through every import in the
consuming codebase is not a fork, it is a vendored copy that never got renamed.

The `infi` namespace package is gone entirely (src/infi/__init__.py with it),
the distribution is `datastore-orm`, and the metadata points at Hanzo rather
than at the upstream repo and author.

NOT renamed, deliberately: the migration history tables are still
`infi_clickhouse_orm_migrations`. That name is persisted state — 448 rows in
production key off it — so changing it is a data migration, not a rename. Doing
it carelessly reproduces the exact failure this fork just hit, where a package
rename orphaned the history and silently blocked every migration.
2026-07-26 08:44:11 -07:00

2.7 KiB

System Models

Clickhouse docs.

System models are read only models for implementing part of the system's functionality, and for providing access to information about how the system is working.

Currently the following system models are supported:

Class DB Table Comments
SystemPart system.parts Gives methods to work with partitions. See below.

Partitions and Parts

ClickHouse docs.

A partition in a table is data for a single calendar month. Table "system.parts" contains information about each part.

Method Parameters Comments
get(static) database, conditions="" Gets database partitions, filtered by conditions
get_active(static) database, conditions="" Gets only active (not detached or dropped) partitions, filtered by conditions
detach settings=None Detaches the partition. Settings is a dict of params to pass to http request
drop settings=None Drops the partition. Settings is a dict of params to pass to http request
attach settings=None Attaches already detached partition. Settings is a dict of params to pass to http request
freeze settings=None Freezes (makes backup) of the partition. Settings is a dict of params to pass to http request
fetch settings=None Fetches partition. Settings is a dict of params to pass to http request

Usage example:

from datastore_orm import Database, SystemPart
db = Database('my_test_db', db_url='http://192.168.1.1:8050', username='scott', password='tiger')
partitions = SystemPart.get_active(db, conditions='')  # Getting all active partitions of the database
if len(partitions) > 0:
    partitions = sorted(partitions, key=lambda obj: obj.name)  # Partition name is YYYYMM, so we can sort so
    partitions[0].freeze()  # Make a backup in /opt/clickhouse/shadow directory
    partitions[0].drop()  # Dropped partition

Note: system.parts stores information for all databases. To be correct, SystemPart model was designed to receive only parts belonging to the given database instance.


<< Schema Migrations | Table of Contents | Contributing >>