Database utilities for scientific computing with SQLite3 and PostgreSQL
Project description
scitex-db
Database utilities for scientific computing.
Interfaces: Python ⭐⭐⭐ (primary) · CLI ⭐ · MCP — · Skills ⭐⭐ · Hook — · HTTP —
Problem and Solution
| # | Problem | Solution |
|---|---|---|
| 1 | Storing ndarrays in SQLite means pickle.dumps → BLOB -- no compression, no type info, no deterministic hashing |
SQLite3.save_array(name, arr) / load_array(name) -- compressed BLOB storage with typed round-trip; compatible with pandas via to_df |
| 2 | sqlite3 API is low-level -- every project re-writes connect/transaction/execute boilerplate |
with db: context-manager transactions -- health checks, duplicate removal, schema inspection built in |
Overview
scitex-db provides enhanced database operations designed for scientific research:
Features
SQLite3 with Scientific Extensions:
- 📊 Array Storage - Store/retrieve NumPy arrays efficiently
- 🔬 Blob Storage - Serialize Python objects with metadata
- 📦 Batch Operations - High-performance bulk inserts
- 🔍 Advanced Queries - Scientific query patterns
- 🗂️ Git Integration - Version control for databases
- 📤 Import/Export - CSV, JSON, DataFrame conversions
- 🔧 Maintenance Tools - Health checks, deduplication
PostgreSQL Support:
- Full-featured PostgreSQL wrapper
- Optimized for scientific datasets
CLI Tools:
scitex-db inspect database.db
scitex-db health database.db --fix
Installation
pip install scitex-db
For PostgreSQL:
pip install scitex-db[postgresql]
For all features:
pip install scitex-db[all]
Quick Start
Basic Usage
from scitex_db import SQLite3
# Initialize
db = SQLite3("experiments.db")
# Create table
db.create_table("results", {
"id": "INTEGER PRIMARY KEY",
"experiment": "TEXT",
"accuracy": "REAL"
})
# Insert data
db.insert_many("results", [
{"experiment": "exp1", "accuracy": 0.95},
{"experiment": "exp2", "accuracy": 0.92}
])
# Query
results = db.get_rows("results", where="accuracy > 0.9")
print(results)
Array Storage
import numpy as np
# Save arrays
data = np.random.rand(1000, 50)
db.save_array("features", data,
column="embeddings",
additional_columns={"model": "bert"})
# Load arrays
loaded = db.load_array("features", "embeddings",
where="model = 'bert'")
Blob Storage
# Store arbitrary objects
model = {"weights": np.random.rand(100), "config": {...}}
db.save_blob("models", model,
column="checkpoint",
additional_columns={"epoch": 10})
# Retrieve
model = db.load_blob("models", "checkpoint", where="epoch = 10")
Git Integration
from scitex_db import SQLite3
db = SQLite3("versioned.db")
db.init_git() # Initialize git tracking
# Automatic commits on changes
db.insert("results", {"value": 42})
# Commits with message: "Insert 1 row(s) into results"
Advanced Features
Transaction Management
with db.transaction():
db.insert("table1", {...})
db.insert("table2", {...})
# Auto-commit on success, rollback on error
Batch Operations
# High-performance bulk insert
large_dataset = [{"id": i, "value": i**2} for i in range(10000)]
db.insert_many("data", large_dataset, batch_size=1000)
Database Inspection
# Get comprehensive summary
db.summary # or db()
# Inspect specific table
db.inspect_table("results")
# Health check
from scitex_db import check_health
check_health("database.db", fix_issues=True)
Part of SciTeX Ecosystem
scitex-core- Core infrastructurescitex-io- Data I/O (can use scitex-db)scitex-writer- Academic writingscitex-scholar- Paper managementscitex- Main package
License
MIT License - see LICENSE file for details.
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 scitex_db-0.1.4.tar.gz.
File metadata
- Download URL: scitex_db-0.1.4.tar.gz
- Upload date:
- Size: 163.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32bfe5b786a3e4f482bf016b7fc51a00ffe1966e432f8164e26785a5adbf87d7
|
|
| MD5 |
f95f3481ac03e806402f11d4cf53f305
|
|
| BLAKE2b-256 |
d0bc92e7316785c7bcca79db333ca052bca88443948f6836db37e5405e88db7b
|
Provenance
The following attestation bundles were made for scitex_db-0.1.4.tar.gz:
Publisher:
publish-pypi.yml on ywatanabe1989/scitex-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_db-0.1.4.tar.gz -
Subject digest:
32bfe5b786a3e4f482bf016b7fc51a00ffe1966e432f8164e26785a5adbf87d7 - Sigstore transparency entry: 1396575471
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-db@4b3f040bb24a279e46f862ed7542538227dad907 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4b3f040bb24a279e46f862ed7542538227dad907 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scitex_db-0.1.4-py3-none-any.whl.
File metadata
- Download URL: scitex_db-0.1.4-py3-none-any.whl
- Upload date:
- Size: 112.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90d4fab696acbee8ac5e9627852c30d08fb2863c6bf1e3cdabd70a37e7f8418c
|
|
| MD5 |
2014b3166215045d7ce6b95825861fd5
|
|
| BLAKE2b-256 |
2c126c822df101e177e88ed8a9478a01059402c5dd10ccf5fde43dd304384e99
|
Provenance
The following attestation bundles were made for scitex_db-0.1.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on ywatanabe1989/scitex-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_db-0.1.4-py3-none-any.whl -
Subject digest:
90d4fab696acbee8ac5e9627852c30d08fb2863c6bf1e3cdabd70a37e7f8418c - Sigstore transparency entry: 1396575492
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-db@4b3f040bb24a279e46f862ed7542538227dad907 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4b3f040bb24a279e46f862ed7542538227dad907 -
Trigger Event:
push
-
Statement type: