A MongoDB-style disk-based database implementation
Project description
SimpleDiskDB
A MongoDB-style disk-based database implementation for Python applications. SimpleDiskDB provides a familiar MongoDB-like interface while storing data locally on disk using the diskcache package.
Features
- MongoDB-like document storage and querying
- Thread-safe operations
- Rich query language supporting
$and,$or,$gt,$exists,$ninoperators - Flexible document schema within collections
- Sorting and pagination support
- Projection support to retrieve specific fields
- Data persistence across application restarts
Installation
# Install the package
pip install simplediskdb
# Load example data (either method works)
simplediskdb --load-example
# or
python -m simplediskdb --load-example
# Delete example data (either method works)
simplediskdb --delete-example
# or
python -m simplediskdb --delete-example
# Show available commands
simplediskdb --help
Usage
from simplediskdb import DiskDB
# Get a database instance
db = DiskDB()
# Create collections
tasks = db.add_collection('tasks')
users = db.add_collection('users')
# Insert documents
tasks.insert_one({
"task_id": "T123",
"status": "pending",
"priority": 1,
"assigned_to": "john",
"files": ["doc1.pdf", "doc2.txt"]
})
# Bulk insert
users.insert_many([
{"name": "John", "role": "admin"},
{"name": "Jane", "role": "user"}
])
# Complex query with AND, OR, and comparison operators
results = tasks.find(
conditions={
"$and": [
{"status": "pending"},
{"$or": [
{"priority": {"$gt": 0}},
{"priority": 0}
]},
{"files": {"$exists": True}}
]
},
sort=[("priority", -1)],
limit=10
)
# Print results
for doc in results:
print(doc)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
We love your input! We want to make contributing to SimpleDiskDB as easy and transparent as possible, whether it's:
- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer
Development Process
- Fork the repo https://github.com/anandan-bs/simplediskdb
- Clone your fork (
git clone https://github.com/anandan-bs/simplediskdb.git) - Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run the tests to ensure nothing is broken
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Pull Request Process
- Update the README.md with details of changes if needed
- Update the example data or tests if your changes require it
- Make sure your code follows the existing style
- Include comments in your code where necessary
Any Questions?
Feel free to file an issue on the repository or contact the maintainer:
- GitHub: @anandan-bs
- Email: anandanklnace@gmail.com
License
By contributing, you agree that your contributions will be licensed under its MIT License.
Acknowledgments
SimpleDiskDB is built on top of the excellent diskcache package, which provides the core storage functionality. Some key performance highlights from diskcache:
- Faster than other disk-based cache implementations like SQLite and LevelDB
- Sequential operations run at ~300 microseconds
- Bulk operations run at ~100 microseconds per operation
- Performance is stable with database size due to O(1) record operations
For detailed performance benchmarks and comparisons with other storage solutions, please refer to the diskcache documentation.
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 simplediskdb-0.1.0.tar.gz.
File metadata
- Download URL: simplediskdb-0.1.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b2126c2848328f6476a2d697493766c286798516a6d922751aeba004f5a01d
|
|
| MD5 |
25febb2224222d38cae24c173810f6d0
|
|
| BLAKE2b-256 |
d4998deb8f9f391455b64f87fe7ea2bb620936fa511930a9ba9d89e5acd6792a
|
Provenance
The following attestation bundles were made for simplediskdb-0.1.0.tar.gz:
Publisher:
python-publish.yml on anandan-bs/simplediskdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplediskdb-0.1.0.tar.gz -
Subject digest:
97b2126c2848328f6476a2d697493766c286798516a6d922751aeba004f5a01d - Sigstore transparency entry: 219565748
- Sigstore integration time:
-
Permalink:
anandan-bs/simplediskdb@d07182c74232f72686ede2b1999d67bca22ed817 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/anandan-bs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d07182c74232f72686ede2b1999d67bca22ed817 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simplediskdb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simplediskdb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e02ec2475897b0e95300a11b4dfab4c670ff48336a9c6947990e9e53d5768c0
|
|
| MD5 |
d588f34963b601d6ea714d7e558f9d99
|
|
| BLAKE2b-256 |
dbd2ac35e19722716e13f618af4b84c1489526ce2272efd6ac515819eb0df30b
|
Provenance
The following attestation bundles were made for simplediskdb-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on anandan-bs/simplediskdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplediskdb-0.1.0-py3-none-any.whl -
Subject digest:
1e02ec2475897b0e95300a11b4dfab4c670ff48336a9c6947990e9e53d5768c0 - Sigstore transparency entry: 219565749
- Sigstore integration time:
-
Permalink:
anandan-bs/simplediskdb@d07182c74232f72686ede2b1999d67bca22ed817 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/anandan-bs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d07182c74232f72686ede2b1999d67bca22ed817 -
Trigger Event:
release
-
Statement type: