# KeyValueSqlite
Super easy drop in replacement for python dictionary, which stores
it's key-value to an sqlite database.
# API
```python
from keyvalue_sqlite import KeyValueSqlite
DB_PATH = '/path/to/db.sqlite'
db = KeyValueSqlite(DB_PATH, 'table-name')
# Now use standard dictionary operators
db.set_default('0', '1')
actual_value = db.get('0')
assert '1' == actual_value
db.set_default('0', '2')
assert '1' == db.get('0')
```
New in 1.0.4: atomic integers.
```python
from keyvalue_sqlite import KeyValueSqlite
DB_PATH = '/path/to/db.sqlite'
db = KeyValueSqlite(DB_PATH, 'table-name')
# Now use standard dictionary operators
db.set_default('atomic_var', '1')
db.atomic_add('atomic_var', '2')
val = db.get('atomic_var')
assert '3' == actual_value
```
This datastructure is not going to win any performance races, but it
is super simple to use with just a few lines of code. This is a great
option for one of those small web apps which doesn't have enough load
to justify mysql or postgres, or a file that will be used by multiple
processes, or to store a file that can't be corrupted during a power
failure.
When fetching large amounts of data try to use get_many() or dict_range().
# Links
* https://pypi.org/project/keyvalue-sqlite
* https://github.com/zackees/keyvalue_sqlite
# Versions
* 1.0.7: Don't use "default" as the default table name, sqlite doesn't like it.
* 1.0.6: Allow setting default timeout in the constructor
* 1.0.5: Makes table name optional.
* 1.0.4: Adds atomic_add to allow atomic int operations.
Raw data
{
"_id": null,
"home_page": "https://github.com/zackees/keyvalue_sqlite",
"name": "keyvalue-sqlite",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6.0",
"maintainer_email": "",
"keywords": "",
"author": "Zach Vorhies",
"author_email": "dont@email.me",
"download_url": "https://files.pythonhosted.org/packages/ac/b1/d4311760127357373c8a361f43cbdfca18e812ea305d9b09e16fd2542d3a/keyvalue_sqlite-1.0.7.tar.gz",
"platform": null,
"description": "# KeyValueSqlite\r\n\r\nSuper easy drop in replacement for python dictionary, which stores\r\nit's key-value to an sqlite database.\r\n\r\n# API\r\n\r\n```python\r\nfrom keyvalue_sqlite import KeyValueSqlite\r\n\r\nDB_PATH = '/path/to/db.sqlite'\r\n\r\ndb = KeyValueSqlite(DB_PATH, 'table-name')\r\n# Now use standard dictionary operators\r\ndb.set_default('0', '1')\r\nactual_value = db.get('0')\r\nassert '1' == actual_value\r\ndb.set_default('0', '2')\r\nassert '1' == db.get('0')\r\n```\r\n\r\nNew in 1.0.4: atomic integers.\r\n\r\n```python\r\nfrom keyvalue_sqlite import KeyValueSqlite\r\n\r\nDB_PATH = '/path/to/db.sqlite'\r\n\r\ndb = KeyValueSqlite(DB_PATH, 'table-name')\r\n# Now use standard dictionary operators\r\ndb.set_default('atomic_var', '1')\r\ndb.atomic_add('atomic_var', '2')\r\nval = db.get('atomic_var')\r\nassert '3' == actual_value\r\n```\r\n\r\nThis datastructure is not going to win any performance races, but it\r\nis super simple to use with just a few lines of code. This is a great\r\noption for one of those small web apps which doesn't have enough load\r\nto justify mysql or postgres, or a file that will be used by multiple\r\nprocesses, or to store a file that can't be corrupted during a power\r\nfailure.\r\n\r\nWhen fetching large amounts of data try to use get_many() or dict_range().\r\n\r\n# Links\r\n * https://pypi.org/project/keyvalue-sqlite\r\n * https://github.com/zackees/keyvalue_sqlite\r\n\r\n# Versions\r\n * 1.0.7: Don't use \"default\" as the default table name, sqlite doesn't like it.\r\n * 1.0.6: Allow setting default timeout in the constructor\r\n * 1.0.5: Makes table name optional.\r\n * 1.0.4: Adds atomic_add to allow atomic int operations.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Super simple keyvalue store for python, backed by sqlite.",
"version": "1.0.7",
"project_urls": {
"Homepage": "https://github.com/zackees/keyvalue_sqlite"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "93f77a75d45245f1deada19acef970b630332f1aa24d5a64fae5281ee5203315",
"md5": "dc0f83cdae2f2250aa326504ac0f4e33",
"sha256": "cf462e805bbd6a03c6765d3f2cce71b4fba5d9a28c6cdee55460bf1f7e492c37"
},
"downloads": -1,
"filename": "keyvalue_sqlite-1.0.7-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "dc0f83cdae2f2250aa326504ac0f4e33",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6.0",
"size": 6385,
"upload_time": "2024-01-08T21:48:35",
"upload_time_iso_8601": "2024-01-08T21:48:35.947449Z",
"url": "https://files.pythonhosted.org/packages/93/f7/7a75d45245f1deada19acef970b630332f1aa24d5a64fae5281ee5203315/keyvalue_sqlite-1.0.7-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "acb1d4311760127357373c8a361f43cbdfca18e812ea305d9b09e16fd2542d3a",
"md5": "b568040982ab37db3b000e75e1996d90",
"sha256": "3dafb036b43a441039f1a2da00810eedae75c23e7b5f8617b775fd9ef3bdf895"
},
"downloads": -1,
"filename": "keyvalue_sqlite-1.0.7.tar.gz",
"has_sig": false,
"md5_digest": "b568040982ab37db3b000e75e1996d90",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.0",
"size": 6523,
"upload_time": "2024-01-08T21:48:36",
"upload_time_iso_8601": "2024-01-08T21:48:36.907373Z",
"url": "https://files.pythonhosted.org/packages/ac/b1/d4311760127357373c8a361f43cbdfca18e812ea305d9b09e16fd2542d3a/keyvalue_sqlite-1.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-08 21:48:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zackees",
"github_project": "keyvalue_sqlite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "keyvalue-sqlite"
}