keyv


Namekeyv JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-09-06 17:33:58
maintainerNone
docs_urlNone
authorrenanmoretto
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # keyv

A lightweight, file-based NoSQL key-value database designed for simple and practical uses. It requires no external dependencies and stores all data locally in a single file. Perfect for applications needing a straightforward and efficient storage solution.

```bash
pip install keyv
```
# How it works
keyv uses sqlite3 as its engine, thereby benefiting from its power, integrity, and practicality. This looks strange but it works like a charm.

# Usage

```python
import keyv

# initialize the database
db = keyv.connect('db.keyv') # or .db, or .anything, you choose
```
###
```python
# insert a key-value pair
db.put('key1', 'value1')

# by default the .put method is unique safe, i.e. it raises an error
# if the key already exists. if you don't want that behavior you can
# use replace_if_exists=True.
db.put('key1', 'value1', replace_if_exists=True)

# retrieve a value by key
value = db.get('key1')
print(value)  # output: 'value1'
# note: the get method returns None for non-existing keys

# update a value
db.update('key1', 123)
updated_value = db.get('key1')
print(updated_value)  # output: 123

# delete a key-value pair
db.delete('key1')

# search for keys by value
db.put('key2', 'common_value')
db.put('key3', 'common_value')
keys = db.search('common_value')
print(keys)  # output: ['key2', 'key3']

# retrieve all keys
all_keys = db.keys()
print(all_keys)  # output: ['key2', 'key3']
```
###
keyv uses pickle to serialize data (keys and values). This means you are free to use any python type that can be serialized using pickle for both keys and values.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "keyv",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "renanmoretto",
    "author_email": "himynameisrenan@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/a8/7f/025cb3f9160abe2b5955233dd0b3853f7d8a6ee935c001293c058e1806b3/keyv-0.1.3.tar.gz",
    "platform": null,
    "description": "# keyv\n\nA lightweight, file-based NoSQL key-value database designed for simple and practical uses. It requires no external dependencies and stores all data locally in a single file. Perfect for applications needing a straightforward and efficient storage solution.\n\n```bash\npip install keyv\n```\n# How it works\nkeyv uses sqlite3 as its engine, thereby benefiting from its power, integrity, and practicality. This looks strange but it works like a charm.\n\n# Usage\n\n```python\nimport keyv\n\n# initialize the database\ndb = keyv.connect('db.keyv') # or .db, or .anything, you choose\n```\n###\n```python\n# insert a key-value pair\ndb.put('key1', 'value1')\n\n# by default the .put method is unique safe, i.e. it raises an error\n# if the key already exists. if you don't want that behavior you can\n# use replace_if_exists=True.\ndb.put('key1', 'value1', replace_if_exists=True)\n\n# retrieve a value by key\nvalue = db.get('key1')\nprint(value)  # output: 'value1'\n# note: the get method returns None for non-existing keys\n\n# update a value\ndb.update('key1', 123)\nupdated_value = db.get('key1')\nprint(updated_value)  # output: 123\n\n# delete a key-value pair\ndb.delete('key1')\n\n# search for keys by value\ndb.put('key2', 'common_value')\ndb.put('key3', 'common_value')\nkeys = db.search('common_value')\nprint(keys)  # output: ['key2', 'key3']\n\n# retrieve all keys\nall_keys = db.keys()\nprint(all_keys)  # output: ['key2', 'key3']\n```\n###\nkeyv uses pickle to serialize data (keys and values). This means you are free to use any python type that can be serialized using pickle for both keys and values.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "add99fdb62de69365c7a6854889785abddd3a7c2684a47f4071000dda03dcf1a",
                "md5": "37a196e43bdc7fd97ba1977976bd1cd4",
                "sha256": "384949d768f0803698ab5278ae1fba4805a16716ba59ac680800eb627cdaef09"
            },
            "downloads": -1,
            "filename": "keyv-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37a196e43bdc7fd97ba1977976bd1cd4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4487,
            "upload_time": "2024-09-06T17:33:57",
            "upload_time_iso_8601": "2024-09-06T17:33:57.153082Z",
            "url": "https://files.pythonhosted.org/packages/ad/d9/9fdb62de69365c7a6854889785abddd3a7c2684a47f4071000dda03dcf1a/keyv-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a87f025cb3f9160abe2b5955233dd0b3853f7d8a6ee935c001293c058e1806b3",
                "md5": "50612e9fed24417d9d19718fad64d561",
                "sha256": "698164d51a6446f5681a750c9c2f29ca4be6209c29ed74fdce80875b1943d2d8"
            },
            "downloads": -1,
            "filename": "keyv-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "50612e9fed24417d9d19718fad64d561",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4221,
            "upload_time": "2024-09-06T17:33:58",
            "upload_time_iso_8601": "2024-09-06T17:33:58.183747Z",
            "url": "https://files.pythonhosted.org/packages/a8/7f/025cb3f9160abe2b5955233dd0b3853f7d8a6ee935c001293c058e1806b3/keyv-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-06 17:33:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "keyv"
}
        
Elapsed time: 0.90896s