Skip to main content

Persistent and portable serialized data store.

Project description

pyDataStore

Persistent and portable serialized data store.

A Python dict object that has been dump-ed can be load-ed or retrieved in the future.

To secure the data, it is using the base64 package when encoding it in Base64, which is the default encoding, and pycryptodome package when encoding it in AES. Then, pickle to serialize the dict object.

Requirements

This requires Python >=3.5, <3.10.

Python Packages

Installation

Install the package through PyPI:

pip install pyDataStore

Usage

As this will be using Python 3, we have to set the shebang to the appropriate executable.

#!/usr/bin/env python3

To use pyDataStore, we have to import it first.

from pyDataStore import Cipher, DataStore

Then, we can use this sample dict object.

# Sample dict object.
objDict = {"object": "test_datastore", "data": {"user": "dummy-user", "pass": "123qwe456asd789zxc"}}

There is a required format for the dict object.

{
    "object": "OBJECT_NAME",
    "data": {
        "DATA_KEY": "DATA_VALUE",
        "DATA_KEY": "DATA_VALUE",
        ...
    }
}

Otherwise, this will throw an Exception.

Exception: This dict object has an invalid format.

Base64 Encoding

  • Using the default data store file.

    print(f"Raw: {objDict}")
    
    # Create an instance that will store the data in a file named data.store (default).
    # Default encoding is set to Base64.
    ds64 = pyDataStore()
    
    # This is the same as the above.
    # ds64 = pyDataStore(fileDataStore="data.store", cipher=Cipher.Base64)
    
    # Dump or store the dictionary object.
    ds64.dump(objDict)
    
    # At this point, the objDict dict object is already encoded.
    
    # Based64 Encoded.
    print(f"Base64: {objDict}")
    
    # Retrieve the stored encoded dict object.
    data64 = ds64.load("test_datastore")
    
    print(f"Decoded: {data64}")
    

AES Encoding

  • Using a custom data store file.

    print(f"Raw: {objDict}")
    
    # Create an instance that will store the data in a file named aes.store.
    # Encoding is set to AES.
    dsAES = pyDataStore(fileDataStore="aes.store", cipher=Cipher.AES, aesKey="SPECIFY_AN_AES_KEY_HERE")
    
    # Dump or store the dictionary object.
    dsAES.dump(objDict)
    
    # At this point, the objDict dict object is already encoded.
    
    # AES Encoded.
    print(f"AES: {objDict}")
    
    # Retrieve the stored encoded dict object.
    dataAES = dsAES.load("test_datastore")
    
    print(f"Decoded: {dataAES}")
    

Contribute

Community contributions are encouraged! Feel free to report bugs and feature requests to the issue tracker provided by GitHub.

License

pyDataStore is an Open-Source Software (OSS) and is available for use under the GNU GPL v3 license.

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

pyDataStore-1.0.6.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

pyDataStore-1.0.6-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file pyDataStore-1.0.6.tar.gz.

File metadata

  • Download URL: pyDataStore-1.0.6.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyDataStore-1.0.6.tar.gz
Algorithm Hash digest
SHA256 1b4cd45153fcf0a1de352b10bea2eff9776462f27a370d4b2a26108f4605d6dc
MD5 8fe76efe32eeb6b6d8bb14a0f94a38de
BLAKE2b-256 d98d9dfe9ae8e1672b3b9837a411c9bdaa948ce6652699e82c1027ebdf7500a8

See more details on using hashes here.

File details

Details for the file pyDataStore-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyDataStore-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pyDataStore-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b57e44b591a27cd7809c13169c538958e8a711a58bcd49ed1724b056834b2913
MD5 387ca9833d4e6db15cad60755ac78910
BLAKE2b-256 84b00527cc91b55671b7a11fcd86eebd17bf6dc684d93605ff3b0dc6633afdc0

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