Python wrapper for zcompact - JSON compaction with queryable ID index
Project description
zcompact
Python wrapper for zcompact - JSON compaction with queryable ID index.
Requirements
The zcompact CLI must be installed:
brew tap zzmarks26/zcompact
brew install zcompact
Installation
pip install /path/to/Zcompact/python
Usage
Create an archive from .gz files
from zcompact import Archive
# Create archive with secondary index
archive = Archive.create_from_files(
"data.jcpk",
["file1.json.gz", "file2.json.gz"],
id_field="id",
index_field="_domain_uuid"
)
Open an existing archive
from zcompact import Archive
archive = Archive("data.jcpk")
Query by primary ID
# Returns dict or None
record = archive.get("user-123")
# Raises RecordNotFoundError if not found
record = archive.get_or_raise("user-123")
Query by secondary index
# Get all records for a company
records = archive.query_index("company-uuid-here")
for record in records:
print(record["name"])
Search by ID prefix
# Get IDs starting with "user-"
ids = archive.search("user-", limit=100)
Insert/Update/Delete
# Insert
archive.insert("new-id", {"id": "new-id", "name": "Alice"})
# Update
archive.update("new-id", {"id": "new-id", "name": "Alice Smith"})
# Delete
archive.delete("new-id")
# Compact to reclaim space
archive.compact()
Get stats
stats = archive.stats()
print(f"Records: {stats['active_records']}")
print(f"Compression ratio: {stats['compression_ratio']}x")
Example: AWS S3 workflow
import boto3
from zcompact import Archive
s3 = boto3.client('s3')
# Download .gz files from S3
files = []
for key in ['data/part1.json.gz', 'data/part2.json.gz']:
local_path = f"/tmp/{key.split('/')[-1]}"
s3.download_file('my-bucket', key, local_path)
files.append(local_path)
# Create searchable archive
archive = Archive.create_from_files(
"records.jcpk",
files,
id_field="id",
index_field="_domain_uuid"
)
# Query
company_records = archive.query_index("some-company-uuid")
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 zcompact-1.0.1.tar.gz.
File metadata
- Download URL: zcompact-1.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc17d7a928e5a048f9917a4c1835fe5658b14ff4bf18cd3b71600ca93d1c5c17
|
|
| MD5 |
75adad6b030eafd3e74f0d2d488b30c4
|
|
| BLAKE2b-256 |
3376529c3703128188d5e90bb6316d0e80c08c90411941499f873477f4243f76
|
Provenance
The following attestation bundles were made for zcompact-1.0.1.tar.gz:
Publisher:
publish.yml on zzmarks26/Zcompact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zcompact-1.0.1.tar.gz -
Subject digest:
bc17d7a928e5a048f9917a4c1835fe5658b14ff4bf18cd3b71600ca93d1c5c17 - Sigstore transparency entry: 840571041
- Sigstore integration time:
-
Permalink:
zzmarks26/Zcompact@cbc6c438b95d64922bf5bd62a6d456931383b57e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zzmarks26
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbc6c438b95d64922bf5bd62a6d456931383b57e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zcompact-1.0.1-py3-none-any.whl.
File metadata
- Download URL: zcompact-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99a1a6ac6750725d126799527ff6c6dc1b279602c1e4dc2642062e1c889997e2
|
|
| MD5 |
eeaabb10637b556eaf95cff9e9e53ba9
|
|
| BLAKE2b-256 |
025b6ba206040c16e16ae63db6c13bd253154a0299c84d90ad5a4864eeb44dc6
|
Provenance
The following attestation bundles were made for zcompact-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on zzmarks26/Zcompact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zcompact-1.0.1-py3-none-any.whl -
Subject digest:
99a1a6ac6750725d126799527ff6c6dc1b279602c1e4dc2642062e1c889997e2 - Sigstore transparency entry: 840571072
- Sigstore integration time:
-
Permalink:
zzmarks26/Zcompact@cbc6c438b95d64922bf5bd62a6d456931383b57e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zzmarks26
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cbc6c438b95d64922bf5bd62a6d456931383b57e -
Trigger Event:
workflow_dispatch
-
Statement type: