Skip to main content

KeyValueSqlite

Super easy drop in replacement for python dictionary, which stores it's key-value to an sqlite database.

API

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.

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

Versions

  • 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.

Metadata

Release files for keyvalue-sqlite 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keyvalue-sqlite 1.0.6
File Size Uploaded
keyvalue_sqlite-1.0.6.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for keyvalue-sqlite 1.0.6
File Interpreter ABI Platform
keyvalue_sqlite-1.0.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 12.8 kB

Release files / keyvalue_sqlite-1.0.6.tar.gz

Download URL keyvalue_sqlite-1.0.6.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
28830745cb4708800638f5d7147f85b4aa234db70baf3a5ba22d0edeaad0bae2
BLAKE2b-256 checksum
How to use checksums
4da989b585fed90ae4e0a2dc0e61a0e26fbede12780241d13920ed707f77f2dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / keyvalue_sqlite-1.0.6-py2.py3-none-any.whl

Download URL keyvalue_sqlite-1.0.6-py2.py3-none-any.whl
Size 6.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
438d441e06cb126423f440091e4c7f6f11440c04ae82021bb0c7208c8979127d
BLAKE2b-256 checksum
How to use checksums
e1d2d57faa39361ccf26191e7d794b3940523bbd0720d677dd1e80996b051454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

1.0.7

2 release files

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page