Zero-config NoSQL backend database as a Python package
Project description
dbini
A lightweight, zero-configuration NoSQL database solution for Python applications
Overview
dbini is a self-contained NoSQL database solution designed for Python applications that need persistent data storage without the complexity of external database setup. It provides a simple, file-based storage system with support for both embedded usage and REST API access, making it ideal for prototyping, small to medium applications, and local-first development.
Key Features
- Zero Configuration: Start using immediately without setup or external dependencies
- Document Storage: Store and query JSON documents with full CRUD operations
- File Management: Integrated file storage and retrieval system
- Atomic Operations: Secure atomic writes ensuring data integrity
- Dual Interface: Use as embedded Python library or standalone REST API server
- Real-time Updates: WebSocket support for live data synchronization
- Query Support: Flexible filtering and pagination capabilities
- Local-first: All data stored within your project directory
Installation
Requirements
- Python 3.9 or higher
- pip package manager
Install from PyPI
pip install dbini
Install from Source
git clone https://github.com/Binidu01/dbini.git
cd dbini
pip install .
Quick Start
Embedded Database Usage
from dbini import DBini
# Initialize database for your project
db = DBini("myproject")
# Create a new document
user_id = db.insert("users", {
"name": "Alice Johnson",
"email": "alice@example.com",
"age": 28
})
# Query documents
users = db.find("users", {"age": {"$gte": 18}})
for user in users:
print(f"User: {user['name']} ({user['age']} years old)")
# Update document
db.update("users", user_id, {"age": 29})
# File storage
file_id = db.save_file("profile_picture.jpg")
db.update("users", user_id, {"profile_picture": file_id})
# Retrieve file
db.load_file(file_id, "downloaded_profile.jpg")
# Delete document
db.delete("users", user_id)
REST API Server
from dbini.server import DBiniServer
# Start API server
server = DBiniServer("myproject")
server.serve(host="localhost", port=8080)
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST |
/v1/{collection} |
Create new document |
GET |
/v1/{collection} |
Query documents with filters |
GET |
/v1/{collection}/{id} |
Get document by ID |
PUT |
/v1/{collection}/{id} |
Update document |
DELETE |
/v1/{collection}/{id} |
Delete document |
POST |
/v1/files |
Upload file |
GET |
/v1/files/{id} |
Download file |
Project Structure
When you initialize a dbini project, the following directory structure is created:
myproject/
├── data/
│ └── users/
│ ├── 550e8400-e29b-41d4-a716-446655440000.json
│ └── 6ba7b810-9dad-11d1-80b4-00c04fd430c8.json
├── files/
│ ├── 123e4567-e89b-12d3-a456-426614174000.jpg
│ └── 987fcdeb-51a2-43d1-9f12-345678901234.png
└── meta/
└── project.json
- data/: Contains JSON documents organized by collection
- files/: Stores uploaded files referenced by unique IDs
- meta/: Project metadata and configuration
Advanced Usage
Query Operations
# Find with filters
results = db.find("products", {
"category": "electronics",
"price": {"$lt": 1000}
}, limit=10)
# Get single document
user = db.find_one("users", {"email": "user@example.com"})
File Operations
# Save file and get reference
file_id = db.save_file("/path/to/document.pdf")
# Associate with document
doc_id = db.insert("documents", {
"title": "Important Document",
"file_ref": file_id,
"uploaded_at": "2024-01-15T10:30:00Z"
})
# Retrieve file
db.load_file(file_id, "/path/to/downloaded_document.pdf")
Architecture
dbini is built with modern Python technologies:
- Core: Pure Python with minimal dependencies
- API Server: FastAPI framework for REST endpoints
- ASGI Server: Uvicorn for high-performance async operations
- Storage: File-based JSON storage with atomic write operations
- Real-time: WebSocket support for live updates
Use Cases
- Rapid Prototyping: Get started with persistent storage immediately
- Small Applications: Perfect for applications with moderate data requirements
- Local Development: Test applications without external database dependencies
- Edge Computing: Lightweight storage for resource-constrained environments
- Offline-first Apps: Applications that need to work without network connectivity
Contributing
We welcome contributions to dbini! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows Python best practices and includes appropriate tests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
- Documentation: GitHub Repository
- Package: PyPI
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Acknowledgments
dbini is inspired by modern database solutions and local-first software principles. Special thanks to the Python community and all contributors who help improve this project.
Made with ❤️ by Binidu01
If you find dbini useful, please consider giving it a ⭐ on GitHub!
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 dbini-0.1.3.tar.gz.
File metadata
- Download URL: dbini-0.1.3.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b88ce95990470b95250e0e0478987342c15a1e7ce845f3a30e0f4e08fe422998
|
|
| MD5 |
ebf219bb8731d26b0e14c60df3507290
|
|
| BLAKE2b-256 |
5b4e2741f6289646d444986ac1bb09afa86dda96f850476a6211e31ef5a3d40a
|
File details
Details for the file dbini-0.1.3-py3-none-any.whl.
File metadata
- Download URL: dbini-0.1.3-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef8445e0f95900d90d57c56a5591d2259796a2a8d625b0877135dcdbe6bde56
|
|
| MD5 |
736569a65151d7ad5d7224a406ad79a9
|
|
| BLAKE2b-256 |
90fea60e4dc7d6557562a1de976af21c4d50f19c01be091723759131086a8554
|