Dante, a document store for Python backed by SQLite
Dante is zero-setup, easy to use document store (NoSQL database) for Python. It's ideal for exploratory programming, prototyping, internal tools and small, simple projects.
Dante can store Python dictionaries or Pydantic models, supports both sync and async mode, and is based on SQLite.
Dante does not support SQL, relations, ACID, aggregation, replication and is emphatically not web-scale. If you need those features, you should choose another database or ORM engine.
Quickstart
-
Install via PyPI:
pip install dante-db
-
Use it with Python dictionaries (example):
from dante import Dante # Create 'mydatabase.db' in current directory and open it # (you can omit the database name to create a temporary in-memory database.) db = Dante("mydatabase.db") # Use 'mycollection' collection (also known as a "table") collection = db["mycollection"] # Insert a dictionary to the database data = {"name": "Dante", "text": "Hello World!"} collection.insert(data) # Find a dictionary with the specified attribute(s) result = collection.find_one(name="Dante") print(result["text"]) new_data = {"name": "Virgil", "text": "Hello World!"} collection.update(new_data, name="Dante")
Under the hood, Dante stores each dictionary in a JSON-encoded TEXT column in a table (one per collection) in the SQLite database.
Use with Pydantic
Dante works great with Pydantic.
Using the same API as with the plain Python objects, you can insert, query and delete Pydantic models (example):
from dante import Dante
from pydantic import BaseModel
class Message(BaseModel):
name: str
text: str
# Open the database and get the collection for messages
db = Dante("mydatabase.db")
collection = db[Message]
# Insert a model to the database
obj = Message(name="Dante", text="Hello world!")
collection.insert(obj)
# Find a model with the specified attribute(s)
result = collection.find_one(name="Dante")
print(result.text)
# Find a model in the collection with the attribute name=Dante
# and update (overwrite) it with the new model data
result.name = "Virgil"
collection.update(result, name="Dante")
Async Dante
Dante supports async usage with the identical API, both for plain Python objects and Pydantic models (example):
from asyncio import run
from dante import AsyncDante
async def main():
db = AsyncDante("mydatabase.db")
collection = await db["mycollection"]
data = {"name": "Dante", "text": "Hello World!"}
await collection.insert(data)
result = await collection.find_one(name="Dante")
print(result["text"])
new_data = {"name": "Virgil", "text": "Hello World!"}
await collection.update(new_data, name="Dante")
await db.close()
run(main())
Examples
Check out the command-line ToDo app, a simple FastAPI CRUD app, and the other examples in the examples directory.
Development
Detailed guide on how to develop, test and publish Dante is available in the Developer documentation.
License (MIT)
Copyright (c) 2024. Senko Rasic
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for dante-db 0.1.1
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 | |
|---|---|---|---|---|
| dante_db-0.1.1.tar.gz | 12.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dante_db-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / dante_db-0.1.1.tar.gz
| Download URL | dante_db-0.1.1.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4da0c604ed391a51f00fb472ce38835f61fee8fbbc2585b6005c1488a87782a9
|
|
BLAKE2b-256 checksum How to use checksums |
20b301d9d7d0f44e7d952b73995394b8c13cbac4c8a0cedd42320f0fdfac96f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.18
|
Release files / dante_db-0.1.1-py3-none-any.whl
| Download URL | dante_db-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
275554c8992e45dc029a4e6bc9dfa625bc8eff17c21e5f7bbedda34c76b15998
|
|
BLAKE2b-256 checksum How to use checksums |
bf1cd2877836a18c4ce1c7d25c3460110c9041389ba2d89f2d830d1c8253bd99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.18
|
Security for dante-db 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.