Mini pickle database
Project description
Table of Contents
About The Project
This framework is used to create a light, easy to use and versatile database that fits perfectly in small projects or in larger tasks requiring a small database for some sort of data management.
Built With
Below you can find a list of all major frameworks/libraries used to bootstrap this project:
Prerequisites
- Python version 3.9 or above
- Pickle
- IDE (VS Code, PyCharm, Thonny etc.)
Installation
python -m pip install mini_pickle_db
Usage
Here is how to framework actually functions:
- Initial steps:
from mini_pickle_db.pickle_db import db
1.1. You can initiate the database class using the:
database = db()
1.2. You should specify the file path of the database document as shown below:
database.db_file = 'file_path'
Note: The Wrapper will automatically create the file, but not the folder, so one must be created manually.
- Document Structure:
2.1. The documents follow a simple Python dictionary format as shown below:
example_doc = {
'key_1': "value_1",
"key_2": "value_2"
}
- Database Usage: 2.1. How to insert a single document in the database:
single_doc = {
"key_1": "value_1",
"key_2": "value_2"
}
db.insert(single_doc)
2.2. How to insert multiple documents in the database:
multiple_docs = [
{
"key_1": "value_1",
"key_2": "value_2"
},
{
"key_3": "value_3",
"key_4": "value_4"
}
]
db.insert(multiple_docs)
Note: The database automatically assigns an ID to every document and is autoincremented.
[
{"key_1": "value_1", "key_2": "value_2", "id": 0},
{"key_1": "value_1", "key_2": "value_2", "id": 1}
]
Note: The data type of the multiple document database is a list of dictionaries.
2.3. How to load the database:
database.load()
Note: It returns a list of dictionaries.
2.4. How to query the database:
2.4.1. Query a single document:
database.query_one({'key_2': 'value'})
Note: It will return only the first document it finds.
2.4.2. Query a multiple documents:
database.query_many({'key_2': 'value'})
Note: It will return all the documents matching the querry in a list format.
2.5. How to delete document:
database.delete_all({'key': 'value'})
Note: It will delete all the documents matching the querry in a list format. For more examples, please refer to the Documentation
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Contact
Marin Dragolov - murrou13@gmail.com
Project Link: https://github.com/murrou-cell/mini_pickle_db
Acknowledgments
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
Hashes for mini_pickle_db-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc0485b9ddd9714c0de2dc201fdf683f44190535c63d890f8a6c8586eeeda1e7 |
|
MD5 | e98330e97506be58c23b10a6e8a5227b |
|
BLAKE2b-256 | c50e3ae5d10f5338db699457f0a2f14da78593689792ed080213958091a97772 |