is a Simple, FileBase and Document Oriented database
Project description
Introduction
PantherDB is a Simple, FileBase and Document Oriented database that you can use in your projects.
Features:
- Document Oriented
- Easy to use
- Written in pure Python +3.8 based on standard type hints
- Handle Database Encryption
- Singleton connection per
db_name
Usage
Database:
-
Create a database:
db: PantherDB = PantherDB('database.pdb')
-
Create an encrypted database:
Required
cyptography
install it withpip install pantherdb[full]
from cryptography.fernet import Fernet key = Fernet.generate_key() # Should be static (You should not generate new key on every run) db: PantherDB = PantherDB('database.pdb', secret_key=key)
-
Access to a collection:
user_collection: PantherCollection = db.collection('User')
-
Delete a collection:
db.collection('User').drop()
Create:
-
Insert document:
user: PantherDocument = db.collection('User').insert_one(first_name='Ali', last_name='Rn')
Get:
-
Find one document:
user: PantherDocument = db.collection('User').find_one(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').find_one()
-
Find first document (alias of
find_one()
):user: PantherDocument = db.collection('User').first(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').first()
-
Find last document:
user: PantherDocument = db.collection('User').last(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').last()
-
Find documents:
users: list[PantherDocument] = db.collection('User').find(last_name='Rn')
or all documents
users: list[PantherDocument] = db.collection('User').find()
-
Count documents:
users_count: int = db.collection('User').count(first_name='Ali')
Update:
-
Update a document:
user: PantherDocument = db.collection('User').find_one(first_name='Ali', last_name='Rn') user.update(name='Saba')
-
Filter and Update a document:
_filter = {'first_name': 'Ali', 'last_name': 'Rn'} is_updated: bool = db.collection('User').update_one(_filter, first_name='Saba')
-
Filter and Update many:
_filter = {'first_name': 'Ali'} updated_count: int = db.collection('User').update_many(_filter, first_name='Saba')
Delete:
-
Delete a document:
user: PantherDocument = db.collection('User').first(first_name='Ali', last_name='Rn') user.delete()
-
Filter and Delete a document:
is_deleted: bool = db.collection('User').delete_one(first_name='Ali', last_name='Rn')
-
Filter and Delete many:
deleted_count: int = db.collection('User').delete_many(last_name='Rn')
TODO:
- Add encryption
- Complete tests TODO
- Add B+ tree
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
pantherdb-2.1.0.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file pantherdb-2.1.0.tar.gz
.
File metadata
- Download URL: pantherdb-2.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e42437080c7e85dc59f886655a24fbee2b22c498248cc77953a8e057d2c956c |
|
MD5 | 39c2af60719393d2474da81a577025ae |
|
BLAKE2b-256 | cca4c9f14cf158dc0e46798db013547b95d761d1f9f270aca769ab18fbb613e0 |
File details
Details for the file pantherdb-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: pantherdb-2.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 081d30b8c4ff7a7eb0af38bbbac06e753cf67146ddde906a57e4ecc631ff434c |
|
MD5 | 51720cca21a29b3fbc29073aba7445ac |
|
BLAKE2b-256 | ca1ac2f5781a6a52fb88e3078e8ce207de5adcad31973ee1f184de1c4ddf57a2 |