SCAI state management library for database migrations
Project description
scai-state
SCAI state management library for database migrations.
Installation
pip install scai-state
Usage
from scai_state import CodeUnitRegistry
from scai_state.types import CodeUnit, SourceMetadata, TargetMetadata, ObjectType, Kind
# Initialize a new registry
registry = CodeUnitRegistry.init("/path/to/repo")
# Or open an existing registry
registry = CodeUnitRegistry.open("/path/to/existing/repo")
# Create a code unit
code_unit = CodeUnit(
kind=Kind.databaseObject,
source=SourceMetadata(
objectType=ObjectType.table,
database="RETAIL_DB",
schema="dbo",
name="Customer",
),
target=TargetMetadata(
objectType=ObjectType.table,
database="RETAIL",
schema="DBO",
name="CUSTOMER",
),
)
# Returns the ID (auto-generated if not provided)
id = registry.create(code_unit)
# Load a code unit
cu = registry.load(id)
# List all code units (with optional filter)
results = registry.list("source.objectType = 'table'")
# Update specific fields
registry.update(id, {"planning.wave": 2})
# Delete a code unit
registry.delete(id)
Testing
Integration tests live in tests/ and cover the full Python -> Rust -> disk -> Rust -> Python round-trip:
| Test file | What it verifies |
|---|---|
test_serialization.py |
FFI round-trip fidelity for all fields, Pydantic alias handling, extensions empty-map preservation |
test_errors.py |
ScaiError.error_code contract across FFI (1001, 1003) |
test_batch.py |
BatchResult wire format with partial failures (1004) |
test_crud.py |
Full CRUD lifecycle, upsert deep-merge semantics |
test_query.py |
find_by_object partial matching with exclude_unset |
Run them from the repo root:
./scripts/run-tests.sh python
Or directly:
cd crates/scai-state-python
maturin develop
pytest tests/ -v
Building from Source
This package requires Rust and maturin to build:
# Install maturin
pip install maturin
# Build and install in development mode
cd crates/scai-state-python
maturin develop
License
Apache-2.0
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 Distributions
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 snowflake_code_unit_registry-0.7.6.tar.gz.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6.tar.gz
- Upload date:
- Size: 137.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86b7fe8fb11661598c9746b315696ac77fd32385c22d07aa8946e77e8a08031c
|
|
| MD5 |
4d21e1da31c9186114a0c52d9d7b83e2
|
|
| BLAKE2b-256 |
0bd86da7cfd1af4259894849f9b352173d241e0b8cf654447313674a2f97999b
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-win_arm64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-win_arm64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.9+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be45df5e55a3cdb52a22fa48ff6276c31ce2e13aaf087eb695237c1b7c741c92
|
|
| MD5 |
934e33e1599c076a82d195a97da1d94a
|
|
| BLAKE2b-256 |
047e5b3f6b371d7d4f834cebc4aabdd2e5697caf847da2a05f585dc82e0cd0f3
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 6.8 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bc61982183ec7252c5245febdc1dfb843b1040ead7bec605a35fb89eb88aba3
|
|
| MD5 |
137d5962e219cd3c8c80b19d0ff07f16
|
|
| BLAKE2b-256 |
5812ad4b98e6138610268b9dc345cf577e0471929b2d0b0ba05920063622e8a8
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 7.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb3cd082cdf5515e43579d49f14fba697916b269ff97a02cbf5361b759f998f0
|
|
| MD5 |
269bef7a552c67244c6e9b27271520b5
|
|
| BLAKE2b-256 |
1974574e809d150f06bfd94c308fa42bc28e61e770a05e3b883d205988d09b31
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-manylinux_2_38_aarch64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-manylinux_2_38_aarch64.whl
- Upload date:
- Size: 6.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.38+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bbcf356976dc77327e190c8a170bd9cc5a148daa59ae47550597d37736ca78c
|
|
| MD5 |
22e23a97d1afe318782751887ae5f259
|
|
| BLAKE2b-256 |
ddb971bedf94b4a81dadf95b3d8db07181136038dc662c0b2b4b80c5a3f20ed4
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afcdf1946230c551c1827a1cf31a4a217ceed9139ca9ebefc03c1d83c93cd6ab
|
|
| MD5 |
7ac40e722ba05575b9e98dd28abbf700
|
|
| BLAKE2b-256 |
ee7e69227c93de3eb50088d8dad112218fc6044994ab20542d2e4aec64acaa3d
|
File details
Details for the file snowflake_code_unit_registry-0.7.6-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: snowflake_code_unit_registry-0.7.6-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.9 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7779c411cd3bc97b600557b6770bf3e06d65af18aa323a000c0d92cea339bf15
|
|
| MD5 |
b473a362430881aeb785f0c38ffe59b1
|
|
| BLAKE2b-256 |
836dc5e82275601c5629629a5612dc9352f6d243989738c4df9a426a76399778
|