Skip to main content

saved-instance is a persistent Python dictionary.

Project description

saved_instance

About

SavedInstance is a persistent Python dictionary. It allows you to store and retrieve data based on key and value in a dictionary format.

Introduction

SavedInstance is:

  • Just dict: For accessing or modifying data, there are no separate methods, you can just work with the same way as a dictionary.
  • Flexi type: SavedInstance can store all python types and custom user defined class
  • Inbuilt secure: Provides a functionality to store the data in encrypted format, it automatically encrypts the data and decrypts it on demand.
  • Thread safe: Designed to work reliably in multi-threaded and multi-processing environments.

Example 1

Alice.py

Alice.py

from saved_instace import simple_storage

simple_storage_obj = simple_storage()

# writing
simple_storage_obj["message"] = "Hello World"

Bob.py

Bob.py

from saved_instance import simple_storage

simple_storage_obj = simple_storage()

# Reading
print(simple_storage_obj["message"])

Getting Started

Install

pip install saved_instance

Config

svd config init --project-name your-project-name

Run above the command in root of your project

Storages

Simple Storage

Simple storage allows you store all python type object using key and value based.

please refer Example 1

Note! :

  • simple storage can't track nested mutable object changes automatically, you have to make copy of the data then make change then resign.
  • please refer Example 2 and Example 3
  • use rich_storage to track nested mutable object changes.

Example 2

!---- Example for mutable object changes can't track automaticaly ----!

>>> from saved_instace import simple_storage

>>> simple_storage_obj = simple_storage()

>>> simple_storage_obj["shops"] = ["shop1", "shop2"]

>>> simple_storage_obj["shops"].append("shop3")

>>> simple_storage_obj["shops"]

>>> ["shop1", "shop2"] # shop3 won't come

Example 3

!---- Solution for mutable object changes. ----!

>>> from saved_instace import simple_storage

>>> simple_storage_obj = simple_storage()

>>> # considered shops already got stored and we are reading it. data is ["shop1", "shop2"].

>>> temp_shops = simple_storage_obj["shops"] # make copy of data.

>>> temp_shops.append("shop3") # update the value

>>> simple_storage_obj["shops"] = temp_shops # write updated data back

>>> simple_storage_obj["shops"]

>>> ["shop1", "shop2", "shop3"]

secure_storage

Secure Storage is allowing you to store data in encrypt format. please refer Example 3. Secure Storage is same as simple storage can't automatically track nested object changes.

Example 3

>>> import saved_instance as sv

>>> secure_storage_obj = sv.secure_storage()      

>>> # Encryption

>>> secure_storage_obj["msg"] = "Hi"

>>> secure_storage_obj["msg"]
b'gAAAAABoEKIbKBQc8vq3Gft4r-_bS07PXNAy-qW8QcrTH4eb9q2cXZoOPSxS8XS9NuPy9jXtBCLH6G184I3zExx4UEZZgGQ9WszHeRX7-VgfaJ7m_8ZmH6Q='

>>> # Manual Decryption

>>> secure_storage_obj,decrypt("msg")
Hi


>>> # Auto Decrypt

>>> secure_storage_obj = sv.secure_storage(auto_decrypt=True)      

>>> secure_storage_obj["msg"] = "Hi"

>>> secure_storage_obj["msg"]
'Hi'

Rich Storage

Rich Storage is advanced version simple storage.

  • It will store all python types and also user defined custom class
  • It automatically tracks nested mutable objects(List, Dict) changes

Example 4

License

MIT

Project details


Download files

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

Source Distribution

saved_instance-0.2.0.tar.gz (48.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saved_instance-0.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file saved_instance-0.2.0.tar.gz.

File metadata

  • Download URL: saved_instance-0.2.0.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for saved_instance-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ded9f4220857143ad254c5a8691385879924efa191a271b49964227651d394c
MD5 5609e12b829953ced5863327d08d660d
BLAKE2b-256 10219e6d744f64d87bcb4e450ffe68ac76fffb73badd8f50a9b99843007f2d09

See more details on using hashes here.

File details

Details for the file saved_instance-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: saved_instance-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for saved_instance-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 521a384972a6fbcfe00e2751c957ee3fdeb454a9bacbb95d3d3dc1d83a482b90
MD5 ef3b98e9f92e8b82aac03d7ba9aaf021
BLAKE2b-256 ad83983942e17f450bac6f9d7061e0169de0cadf7d8236130cf97777a16c304f

See more details on using hashes here.

Supported by

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