A secure and lightweight database engine with BLAKE2 hashing and LZMA compression for Python applications
Project description
RibbitXDB
RibbitXDB is a secure and lightweight database engine for Python applications, designed as an enhanced alternative to SQLite3. It combines the simplicity of SQLite3 with advanced security features (BLAKE2 hashing) and LZMA compression for optimal storage efficiency.
Features
- SQLite3-Compatible API: Drop-in replacement with familiar interface
- BLAKE2 Hashing: Built-in data integrity verification for every row
- LZMA Compression: Automatic compression reduces database file size by up to 70%
- B-tree Indexing: Fast query performance with efficient indexing
- ACID Transactions: Full transaction support with commit/rollback
- Page-Based Storage: Efficient memory management with configurable caching
- Zero Dependencies: Built entirely on Python standard library
- Lightweight: Ideal for embedded applications and microservices
Installation
pip install ribbitxdb
Quick Start
import ribbitxdb
# Create/connect to database
conn = ribbitxdb.connect('myapp.rbx')
cursor = conn.cursor()
# Create table
cursor.execute('''
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE
)
''')
# Insert data
cursor.execute("INSERT INTO users VALUES (1, 'Alice', 'alice@example.com')")
cursor.execute("INSERT INTO users VALUES (2, 'Bob', 'bob@example.com')")
conn.commit()
# Query data
cursor.execute("SELECT * FROM users WHERE id = 1")
print(cursor.fetchall())
# Close connection
conn.close()
Advanced Usage
Context Manager
import ribbitxdb
with ribbitxdb.connect('myapp.rbx') as conn:
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")
for row in cursor:
print(row)
Custom Compression Level
# Higher compression (slower, smaller files)
conn = ribbitxdb.connect('myapp.rbx', compression_level=9)
# Lower compression (faster, larger files)
conn = ribbitxdb.connect('myapp.rbx', compression_level=3)
Transactions
conn = ribbitxdb.connect('myapp.rbx')
try:
cursor = conn.cursor()
cursor.execute("INSERT INTO users VALUES (3, 'Charlie', 'charlie@example.com')")
cursor.execute("INSERT INTO users VALUES (4, 'Diana', 'diana@example.com')")
conn.commit()
except Exception as e:
conn.rollback()
print(f"Transaction failed: {e}")
finally:
conn.close()
Supported SQL Operations
- CREATE TABLE: Define table schemas with constraints
- DROP TABLE: Remove tables
- INSERT: Add new records
- SELECT: Query data with WHERE clauses
- UPDATE: Modify existing records
- DELETE: Remove records
Data Types
INTEGER: Whole numbersREAL: Floating-point numbersTEXT: String dataBLOB: Binary dataNULL: Null values
Constraints
PRIMARY KEY: Unique identifierNOT NULL: Required fieldUNIQUE: Unique values
Performance
RibbitXDB is optimized for:
- Fast Reads: B-tree indexes enable O(log n) lookups
- Efficient Storage: LZMA compression reduces file size significantly
- Low Memory: Page-based caching minimizes RAM usage
- Data Integrity: BLAKE2 hashing ensures data authenticity
Benchmarks
| Operation | RibbitXDB | SQLite3 |
|---|---|---|
| Insert 10K rows | 0.8s | 0.6s |
| Select with index | 0.002s | 0.001s |
| File size (10K rows) | 45 KB | 140 KB |
Security
Every row in RibbitXDB is protected with BLAKE2 hashing:
- Data Integrity: Automatic verification on read
- Tamper Detection: Detects unauthorized modifications
- Cryptographic Strength: BLAKE2b with 32-byte digests
Use Cases
RibbitXDB is ideal for:
- Python Applications: Embedded database for desktop/mobile apps
- Microservices: Lightweight data storage
- IoT Devices: Minimal footprint with compression
- Data Archival: Secure, compressed long-term storage
- Prototyping: Quick database setup without external dependencies
API Reference
Connection
conn = ribbitxdb.connect(database, compression_level=6)
database: Path to database filecompression_level: LZMA compression level (0-9, default: 6)
Cursor Methods
execute(sql, parameters=None): Execute SQL statementexecutemany(sql, seq_of_parameters): Execute SQL with multiple parameter setsfetchone(): Fetch next rowfetchmany(size=None): Fetch multiple rowsfetchall(): Fetch all remaining rows
Connection Methods
cursor(): Create new cursorcommit(): Commit current transactionrollback(): Rollback current transactionclose(): Close database connection
Development
Running Tests
pip install pytest pytest-cov
pytest tests/
Building from Source
git clone https://github.com/ribbitx/ribbitxdb.git
cd ribbitxdb
pip install -e .
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Support
- Issues: GitHub Issues
- Documentation: GitHub README
Roadmap
- Query optimizer
- Connection pooling
- Full-text search
- Replication support
- Encryption at rest
Made with ❤️ by the RibbitX Team
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 ribbitxdb-1.0.0.tar.gz.
File metadata
- Download URL: ribbitxdb-1.0.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53eb60835288dbb7e7f4a988d3b8e40039b36b92db3bf29745cfc07d92337358
|
|
| MD5 |
d0c6ca67d39a8314b996c3bd7b6f733c
|
|
| BLAKE2b-256 |
52b139700bc8e2285ed7b83e4486f5f436067e44890c0c9bd054d26b3e79c0b8
|
File details
Details for the file ribbitxdb-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ribbitxdb-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
155867da1f033f654d7b0380ca1e785c06d8dcc48ba2027f3c011acf054c7da4
|
|
| MD5 |
4521c86edd020111f374f987993a4bb0
|
|
| BLAKE2b-256 |
ad990728254a8d05733252dfd8da64dde0dd33b91350f3b6e09627c4d6958439
|