nonbloat-db
Simple key-value database for my small projects!
The idea is to have a dead simple database, which doesn't require spinning up a
server (like Redis), is not underwhelming with features (like SQLite or SQL in
general), data inside can be easily manually reviewed and modified and it
doesn't corrupt (if you just dump JSON into file using json.dump, if the
program was forced to stop during write (e.g. because of power outage),
the data will be corrupted).
The purpose of this project is to serve as a database library for my small projects. So obviously this solution doesn't scale to thousands of users, and it was never intended to. Use right tool for right job.
Also, do note, that everything is async. There is no synchronous version, because all of my projects are generally async. I maybe will add a synchronous wrapper, but I don't promise.
How does it work?
It is just a really simple key-value storage:
import asyncio
from nbdb.storage import Storage
async def main():
# you need to provide a path to database
my_db = await Storage.init("data/db.json")
await my_db.set("abc", 123)
value = await my_db.get("abc")
print(value) # 123
await my_db.write()
if __name__ == "__main__":
asyncio.run(main())
In the background, a lot of things are happening. For example, when you call
.set, the db writes the operation to special AOF (Append Only File; this is
what Redis uses
to achieve data persistence).
And on every write, library renames db.json to db.json.temp and then writes
to db.json new data. This is done to not corrupt data in case of power outage
or force shutdown. If library during initial read finds a .temp file next to
database, it will output a warning and read from temp file.
Installing
It is not yet published to PyPI, so good luck.
pip install nonbloat-db
Installing for local developing
git clone https://github.com/PerchunPak/nonbloat-db.git
cd nonbloat-db
Installing poetry
Next we need install poetry with recommended way.
If you use Linux, use command:
curl -sSL https://install.python-poetry.org | python -
If you use Windows, open PowerShell with admin privileges and use:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
Installing dependencies
poetry install
If something is not clear
You can always write me!
Thanks
This project was generated with python-template.
Metadata
Release files for nonbloat-db 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonbloat_db-0.1.4.tar.gz | 18.8 kB | With provenance | Details for nonbloat_db-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonbloat_db-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for nonbloat_db-0.1.4-py3-none-any.whl |
Total release size: 36.3 kB
Release files / nonbloat_db-0.1.4.tar.gz
| Download URL | nonbloat_db-0.1.4.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04c3ad51a9ce1a61495face1c9c0c58a4097108c5b195ae7088519459003f09b
|
|
BLAKE2b-256 checksum How to use checksums |
7584f334016ef27617d0be93f2fd6449ad69c22d4430104d6788f7e159d64344
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency logRelease files / nonbloat_db-0.1.4-py3-none-any.whl
| Download URL | nonbloat_db-0.1.4-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13b69b5a70949c0e914e1c2f8c04ebd7cc1cab466a4b2c21822f8ac56f0f51d8
|
|
BLAKE2b-256 checksum How to use checksums |
6ac0b23e36c2f990c3c72c733058cbae3984b9d4eee9c64e34123cdbc404c13a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency logSecurity for nonbloat-db 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nonbloat_db-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.