PantherDB is a Simple, FileBase and Document Oriented database that you can use in your projects.
- Document Oriented
- Easy to use
- Written in pure Python +3.8 based on standard type hints
- Handle Database Encryption
- Singleton connection per
db_name
-
db: PantherDB = PantherDB('database.pdb')
-
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)
-
user_collection: PantherCollection = db.collection('User')
-
db.collection('User').drop()
-
user: PantherDocument = db.collection('User').insert_one(first_name='Ali', last_name='Rn')
-
user: PantherDocument = db.collection('User').find_one(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').find_one()
-
user: PantherDocument = db.collection('User').first(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').first()
-
user: PantherDocument = db.collection('User').last(first_name='Ali', last_name='Rn')
or
user: PantherDocument = db.collection('User').last()
-
users: list[PantherDocument] = db.collection('User').find(last_name='Rn')
or all documents
users: list[PantherDocument] = db.collection('User').find()
-
users_count: int = db.collection('User').count(first_name='Ali')
-
user: PantherDocument = db.collection('User').find_one(first_name='Ali', last_name='Rn') user.update(name='Saba')
-
_filter = {'first_name': 'Ali', 'last_name': 'Rn'} is_updated: bool = db.collection('User').update_one(_filter, first_name='Saba')
-
_filter = {'first_name': 'Ali'} updated_count: int = db.collection('User').update_many(_filter, first_name='Saba')
-
user: PantherDocument = db.collection('User').first(first_name='Ali', last_name='Rn') user.delete()
-
is_deleted: bool = db.collection('User').delete_one(first_name='Ali', last_name='Rn')
-
deleted_count: int = db.collection('User').delete_many(last_name='Rn')
- Add encryption
- Complete tests TODO
- Add B+ tree