SEKM migration utility: Elasticsearch → MongoDB/Beanie
Project description
sysnet-sekm-migrate
Migration utility for SEKM — transfers data from Elasticsearch indexes into
MongoDB documents managed by Beanie and sysnet-docversion.
Depends on sysnet-sekm-model for the
domain and persistence models.
Installation
pip install sysnet-sekm-migrate
Requirements
- Python ≥ 3.12
- Access to the source Elasticsearch cluster
- Access to a target MongoDB instance
.envfile with both ES and Mongo credentials (see below)
Configuration
Create a .env file (or export environment variables):
ELK_URI=https://your-es-host:9200
ELK_USER=elastic
ELK_PASSWORD=...
MONGO_HOST=localhost
MONGO_PORT=27017
MONGO_USERNAME=...
MONGO_PASSWORD=...
MONGO_DB=sekm
CLI usage
After installation the sekm-migrate command is available:
# Migrate everything (all 21 entities)
sekm-migrate
# Single entity
sekm-migrate --entity area-source
# Multiple entities
sekm-migrate --entity area-source --entity user
# Dry run — reads ES, validates, but writes nothing to MongoDB
sekm-migrate --entity area-source --dry-run
# Skip archive version history (faster)
sekm-migrate --entity as-object --no-history
# Limit documents (trial run)
sekm-migrate --entity sample --limit 10000
# List all 21 entity names
sekm-migrate --list-entities
# Verbose logging
sekm-migrate --log-level DEBUG
Programmatic usage
from sysnet_sekm_model.config import MongoSettings
from sysnet_sekm_model.db import init_mongo, close_mongo
from sysnet_sekm_migrate.services.elasticsearch import es_client
from sysnet_sekm_migrate.services.migration import migrate_all
settings = MongoSettings()
client = await init_mongo(settings.mongo_uri, settings.mongo_db)
try:
async with es_client() as es:
results = await migrate_all(
es,
entity_names=["area-source", "user"], # None = all entities
import_history=True,
dry_run=False,
)
finally:
await close_mongo(client)
for entity, result in results.items():
result.log_summary()
Supported entities
| Entity | Collection | Versioned | ~Documents |
|---|---|---|---|
area-source |
area_sources |
Yes | 29 000 |
as-object |
as_objects |
Yes | 177 000 |
as-region |
as_regions |
Yes | 2 800 |
as-document |
as_documents |
Yes | 17 000 |
observation |
observations |
Yes | 19 000 |
user |
users |
Yes | 9 200 |
organisation |
organisations |
Yes | 308 |
template |
templates |
Yes | 6 500 |
dictionary |
dictionaries |
Yes | 39 |
substance |
substances |
Yes | 365 |
sample |
samples |
No | ~15 300 000 |
sample-advanced |
samples_advanced |
No | ~13 600 000 |
history |
history_events |
No | 287 000 |
lock |
lock_events |
No | 106 000 |
approval |
approvals |
No | 302 |
region |
regions |
No | 14 |
district |
districts |
No | 77 |
municipality |
municipalities |
No | 6 300 |
orp-district |
orp_districts |
No | 206 |
pou-district |
pou_districts |
No | 394 |
registry |
registry_entries |
No | 13 000 |
Migration is idempotent — it can be run multiple times against the same MongoDB database. Already-migrated documents are detected and skipped.
Documentation
| Document | Contents |
|---|---|
| Migration Guide | Full pipeline description, CLI reference, transformation details |
| Data Model | Domain and persistence model reference |
| Trial Migration Report | Trial migration results and entity volumes |
| Data Quality Report | Post-migration data quality findings and remediation |
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sysnet_sekm_migrate-0.2.0.tar.gz.
File metadata
- Download URL: sysnet_sekm_migrate-0.2.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc2c5088ca6fa1bb535bfe2c12137a7cf037aa0ec49ec42b940197e19c9e6cca
|
|
| MD5 |
deea7ec6b9b0cfdaec65cadc408c318a
|
|
| BLAKE2b-256 |
a23c6dca7454bf99f66e29e6ca92b784170c1d16b63e577c331ee19eac74ab48
|
File details
Details for the file sysnet_sekm_migrate-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sysnet_sekm_migrate-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70babb34f1caf5befe128b6213ac930ca90874ce57ce544025875b4098692645
|
|
| MD5 |
3d92a567f25228649295ffa2d8c24054
|
|
| BLAKE2b-256 |
4ff2a61f9cf8e2510dbebd2a03be040a01af7cddaff01d50a035616dd3cb097c
|