Skip to main content

List wrapper, that pickles it on every update

Project description

store_var

Wrapper, that stores a list into a file on every list update. A band-aid solution for a small project, when database is an overkill.

from store_var import stored

# Stores to file on first initializaiton
users = stored('users.pickle', [
    {'name': 'Gregory', 'age': 45},
    {'name': 'James', 'age': 37},
])

# Behaves as a list
print(f"There are {len(users)} users") # → There are 2 users

# On each change, storage file is updated
users.append({'name': 'Lisa', 'age': 38})

# ··· After restarting a REPL ···

users = stored('users.pickle')
print(users)
# → stored({'name': 'Gregory', 'age': 45}, {'name': 'James', 'age': 37}, {'name': 'Lisa', 'age': 38})
# Notice, that there are 3 users now

Installation

pip install store_var

Limitations

Wrappers for reverse, sort, copy and deepcopy are not implemented yet. Everything else works and is unit-tested.

Stores data using pickle.

Supports only a lists of picklable objects. Won't store a dict, or a list of lambdas.

Examples

See tests.

Project details


Release history Release notifications | RSS feed

This version

1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

store_var-1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

store_var-1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file store_var-1.tar.gz.

File metadata

  • Download URL: store_var-1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for store_var-1.tar.gz
Algorithm Hash digest
SHA256 4cfa6dd552ce2ea610f89cfce0ccfdeb5421c9203b5c9ed92e73f3f808033d5d
MD5 391792df72f0fbd1fda47a1b0b701580
BLAKE2b-256 8af854d99b568a6a903fe36c1f859a4b21c848222f38d799651ed11fef2714d3

See more details on using hashes here.

File details

Details for the file store_var-1-py3-none-any.whl.

File metadata

  • Download URL: store_var-1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for store_var-1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2f5dff3c19ced16b11fe3cc80f20fe02a388615334d7ef2d24c212dcaa026ba
MD5 8bb06f6fb27801e004635d8f0d18d1fb
BLAKE2b-256 eb8aa6c98f3af9c2bc638c9aec6940529bb3c0118ee402a917ce634622475596

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page