<div align="center">
<img src="https://i.imgur.com/NcSTdBc.jpg" alt="QuickSave Banner" style="width: auto; height: auto; max-height: 300px;">
</div>
# QuickSave
![Python Version](https://img.shields.io/pypi/pyversions/qsave)
![PyPI Version](https://img.shields.io/pypi/v/qsave)
![License](https://img.shields.io/pypi/l/qsave)
![Total Downloads](https://static.pepy.tech/badge/qsave)
QuickSave is a fast, memory-efficient, and lightweight key-value database designed for use in small applications. It operates as a pure Python solution, offering a dictionary-like interface for easy integration. QuickSave works efficiently without dependencies, but if you want to boost its performance even further, you can install `msgspec`, which significantly enhances its speed.
---
### [Documentation](https://nasrollahyusefi.github.io/QuickSave/)
## ๐ Table of Contents
- [Why QuickSave?](#why-quicksave)
- [Installation](#installation)
- [Getting Started](#getting-started)
- [Examples](#examples)
- [License](#license)
---
## Why QuickSave?
QuickSave stands out for its speed, memory efficiency, and simplicity. Here are some of the key reasons you should consider using it:
- ๐ **High Performance**: QuickSave is designed to be fast, with minimal overhead.
- ๐ก **Low Memory Usage**: The library is optimized for memory efficiency, making it a great choice for projects with limited resources.
- ๐งต **Thread-Safe**: It supports thread-safe operations, ensuring that it works reliably in concurrent environments.
- ๐๏ธ **Boosted Performance with `msgspec`**: By installing the optional `msgspec` library, you can further enhance QuickSave's performance, especially when handling complex data types.
- ๐ง **No Dependencies**: QuickSave is a pure Python library, which means it has no external dependencies, making it easy to install and use in any Python project.
---
## Installation
Install QuickSave using pip:
```bash
pip install --upgrade qsave
```
Optionally, install `msgspec` to boost performance:
```bash
pip install msgspec==0.19.0
```
## Getting Started
To start using QuickSave, import it and initialize your database:
```python
from qsave import QuickSave
db = QuickSave(path="path/to/your/file.json", pretty=True)
```
The pretty argument beautifies the saved data for better readability (optional).
---
## Examples
#### Basic Usage
By default, changes are automatically saved when the `with` block ends:
```python
with db.session() as session:
session["key"] = "value"
print(session.get("key")) # Output: None, not yet saved
# Exiting the block automatically commits changes
with db.session() as session:
print(session.get("key")) # Output: value
```
#### Manual Commit (commit_on_expire=False)
For full control over when changes are saved, use commit_on_expire=False:
```python
with db.session(commit_on_expire=False) as session:
session["key"] = "manual_value"
print(session.get("key")) # Output: None, not yet saved
session.commit() # Now changes are saved
print(session.get("key")) # Output: manual_value
with db.session() as session:
print(session.get("key")) # Output: manual_value
```
#### Commit and Rollback
You can manually save or discard changes during a session:
```python
with db.session() as session:
session["key"] = "temp_value"
session.rollback() # Discard changes
print(session.get("key")) # Output: None
```
#### Nested Data
```python
with db.session() as session:
session["nested"] = {"key": [1, 2, 3]}
session.commit()
with db.session() as session:
print(session["nested"]) # Output: {"key": [1, 2, 3]}
```
---
## License
This repository is licensed under [MIT License](https://qsave.github.com/).
Raw data
{
"_id": null,
"home_page": null,
"name": "qsave",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": "jsondb, quicksave, key-value, database, lightweight, memory-efficient, json",
"author": "Nasrollah Yusefi nasrollahyusefi2004@gmail.com",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/3f/64/bf0f1da1c1c266b4421e05c5ad87f872a76c2f1de3e4dd74f6836267c8b1/qsave-1.0.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <img src=\"https://i.imgur.com/NcSTdBc.jpg\" alt=\"QuickSave Banner\" style=\"width: auto; height: auto; max-height: 300px;\">\n</div>\n\n# QuickSave\n\n![Python Version](https://img.shields.io/pypi/pyversions/qsave)\n![PyPI Version](https://img.shields.io/pypi/v/qsave)\n![License](https://img.shields.io/pypi/l/qsave)\n![Total Downloads](https://static.pepy.tech/badge/qsave)\n\nQuickSave is a fast, memory-efficient, and lightweight key-value database designed for use in small applications. It operates as a pure Python solution, offering a dictionary-like interface for easy integration. QuickSave works efficiently without dependencies, but if you want to boost its performance even further, you can install `msgspec`, which significantly enhances its speed.\n\n---\n\n### [Documentation](https://nasrollahyusefi.github.io/QuickSave/)\n## \ud83d\udcd6 Table of Contents\n- [Why QuickSave?](#why-quicksave)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Examples](#examples)\n- [License](#license)\n\n---\n\n## Why QuickSave?\n\nQuickSave stands out for its speed, memory efficiency, and simplicity. Here are some of the key reasons you should consider using it:\n\n- \ud83d\ude80 **High Performance**: QuickSave is designed to be fast, with minimal overhead.\n- \ud83d\udca1 **Low Memory Usage**: The library is optimized for memory efficiency, making it a great choice for projects with limited resources.\n- \ud83e\uddf5 **Thread-Safe**: It supports thread-safe operations, ensuring that it works reliably in concurrent environments.\n- \ud83c\udfce\ufe0f **Boosted Performance with `msgspec`**: By installing the optional `msgspec` library, you can further enhance QuickSave's performance, especially when handling complex data types.\n- \ud83d\udd27 **No Dependencies**: QuickSave is a pure Python library, which means it has no external dependencies, making it easy to install and use in any Python project.\n\n---\n\n## Installation\nInstall QuickSave using pip:\n\n```bash\npip install --upgrade qsave\n```\nOptionally, install `msgspec` to boost performance:\n```bash\npip install msgspec==0.19.0\n```\n\n## Getting Started\n\nTo start using QuickSave, import it and initialize your database:\n```python\nfrom qsave import QuickSave\n\ndb = QuickSave(path=\"path/to/your/file.json\", pretty=True)\n```\nThe pretty argument beautifies the saved data for better readability (optional).\n\n---\n\n## Examples\n\n#### Basic Usage\nBy default, changes are automatically saved when the `with` block ends:\n```python\nwith db.session() as session:\n session[\"key\"] = \"value\"\n print(session.get(\"key\")) # Output: None, not yet saved\n\n# Exiting the block automatically commits changes\nwith db.session() as session:\n print(session.get(\"key\")) # Output: value\n```\n\n#### Manual Commit (commit_on_expire=False)\nFor full control over when changes are saved, use commit_on_expire=False:\n```python\nwith db.session(commit_on_expire=False) as session:\n session[\"key\"] = \"manual_value\"\n print(session.get(\"key\")) # Output: None, not yet saved\n session.commit() # Now changes are saved\n print(session.get(\"key\")) # Output: manual_value\n\nwith db.session() as session:\n print(session.get(\"key\")) # Output: manual_value\n```\n\n#### Commit and Rollback\nYou can manually save or discard changes during a session:\n```python\nwith db.session() as session:\n session[\"key\"] = \"temp_value\"\n session.rollback() # Discard changes\n print(session.get(\"key\")) # Output: None\n```\n\n#### Nested Data\n```python\nwith db.session() as session:\n session[\"nested\"] = {\"key\": [1, 2, 3]}\n session.commit()\n\nwith db.session() as session:\n print(session[\"nested\"]) # Output: {\"key\": [1, 2, 3]}\n```\n\n---\n\n## License\nThis repository is licensed under [MIT License](https://qsave.github.com/).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "QuickSave is a fast, memory-efficient, and lightweight key-value database.",
"version": "1.0.1",
"project_urls": {
"Documentation": "https://nasrollahyusefi.github.io/QuickSave/",
"Repository": "https://github.com/NasrollahYusefi/QuickSave",
"homepage": "https://github.com/NasrollahYusefi/QuickSave"
},
"split_keywords": [
"jsondb",
" quicksave",
" key-value",
" database",
" lightweight",
" memory-efficient",
" json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2c7f779fc2c24e76b398e4a5af4a5b245263479d6bfed462c6c1907decfb750a",
"md5": "31a14b21985cf7c55daad1627da527bc",
"sha256": "36882b8d48d7ed076aeaa6043a3c446fa013820fd5156232ab3eda00c22dc7b8"
},
"downloads": -1,
"filename": "qsave-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "31a14b21985cf7c55daad1627da527bc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 6368,
"upload_time": "2025-01-10T00:11:35",
"upload_time_iso_8601": "2025-01-10T00:11:35.308496Z",
"url": "https://files.pythonhosted.org/packages/2c/7f/779fc2c24e76b398e4a5af4a5b245263479d6bfed462c6c1907decfb750a/qsave-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3f64bf0f1da1c1c266b4421e05c5ad87f872a76c2f1de3e4dd74f6836267c8b1",
"md5": "cc61390bbbc454a634f49855d1ffbcae",
"sha256": "0004979f1f452114ff0d4cc1d24aa992bf40e08865d6b3625a62fe4dd3d07cc2"
},
"downloads": -1,
"filename": "qsave-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "cc61390bbbc454a634f49855d1ffbcae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 4832,
"upload_time": "2025-01-10T00:11:37",
"upload_time_iso_8601": "2025-01-10T00:11:37.082662Z",
"url": "https://files.pythonhosted.org/packages/3f/64/bf0f1da1c1c266b4421e05c5ad87f872a76c2f1de3e4dd74f6836267c8b1/qsave-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-10 00:11:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NasrollahYusefi",
"github_project": "QuickSave",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "qsave"
}