qsave


Nameqsave JSON
Version 1.1.2 PyPI version JSON
download
home_pageNone
SummaryQuickSave is a fast, memory-efficient, and lightweight key-value database.
upload_time2025-01-25 10:56:03
maintainerNone
docs_urlNone
authorNasrollah Yusefi nasrollahyusefi2004@gmail.com
requires_python<4.0,>=3.7
licenseMIT
keywords jsondb quicksave key-value database lightweight memory-efficient json
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <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.
- ๐Ÿ”€ **Both sync and async support**: You can use either sync or async version of QuickSave.
- ๐ŸŽ๏ธ **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
```

If you want use async version of QuickSave:
```bash
pip install qsave[async]
```

## 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]}
```

#### Async version:
```python
from qsave.asyncio import AsyncQuickSave

db = AsyncQuickSave("path/to/your/file.json")

async def main():
    async with db.session(False) as session:
        print(len(session))
        await session.commit()
        await session.rollback()  # NOTE: after commit, rollback does nothing :(
        # only commit and rollback need to be awaited
        # other functionalities remain the same as sync version
```

---

## 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/ae/d7/ed8c1040e94d12ee6b501e15c5d3e9a86fcac2b251ecd2951f7ab161d6dd/qsave-1.1.2.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- \ud83d\udd00 **Both sync and async support**: You can use either sync or async version of QuickSave.\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```bash\npip install --upgrade qsave\n```\n\nOptionally, install `msgspec` to boost performance:\n```bash\npip install msgspec==0.19.0\n```\n\nIf you want use async version of QuickSave:\n```bash\npip install qsave[async]\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#### Async version:\n```python\nfrom qsave.asyncio import AsyncQuickSave\n\ndb = AsyncQuickSave(\"path/to/your/file.json\")\n\nasync def main():\n    async with db.session(False) as session:\n        print(len(session))\n        await session.commit()\n        await session.rollback()  # NOTE: after commit, rollback does nothing :(\n        # only commit and rollback need to be awaited\n        # other functionalities remain the same as sync version\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.1.2",
    "project_urls": {
        "Documentation": "https://nasrollahyusefi.github.io/QuickSave/",
        "Homepage": "https://github.com/NasrollahYusefi/QuickSave"
    },
    "split_keywords": [
        "jsondb",
        " quicksave",
        " key-value",
        " database",
        " lightweight",
        " memory-efficient",
        " json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2889440d5eacd58d2788c9ce28c0769a937664208448424a7ba2aa65e7b5776e",
                "md5": "4b7adc39a0286edece14882ceffcf47f",
                "sha256": "b1b10dc13331ac78ae45afdd38166b31df89e3ef6e95c53a679a699732f9bae3"
            },
            "downloads": -1,
            "filename": "qsave-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4b7adc39a0286edece14882ceffcf47f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 9100,
            "upload_time": "2025-01-25T10:56:01",
            "upload_time_iso_8601": "2025-01-25T10:56:01.468775Z",
            "url": "https://files.pythonhosted.org/packages/28/89/440d5eacd58d2788c9ce28c0769a937664208448424a7ba2aa65e7b5776e/qsave-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aed7ed8c1040e94d12ee6b501e15c5d3e9a86fcac2b251ecd2951f7ab161d6dd",
                "md5": "b3f897ab77a6d58802acf8348f4a788b",
                "sha256": "b38fda848b5b7f4f80452033cae4a6548c93cd2c408f1ace13556a96e135d46d"
            },
            "downloads": -1,
            "filename": "qsave-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b3f897ab77a6d58802acf8348f4a788b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 5635,
            "upload_time": "2025-01-25T10:56:03",
            "upload_time_iso_8601": "2025-01-25T10:56:03.527930Z",
            "url": "https://files.pythonhosted.org/packages/ae/d7/ed8c1040e94d12ee6b501e15c5d3e9a86fcac2b251ecd2951f7ab161d6dd/qsave-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-25 10:56:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NasrollahYusefi",
    "github_project": "QuickSave",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "qsave"
}
        
Elapsed time: 2.99242s