Skip to main content

JSON Storage Manager for JSON data stored in text-files

Project description

Build Status License PyPI version Codacy Badge Codacy Badge Documentation Status

json-storage-manager

json-storage-manager is a Python Package that simply manages the JSON files with the stored data of products and orders for a demo store API.

Installation

pip install json-storage-manager

atomic

Usage

atomic is basically used as a custom context manager for writing JSON files without downtime for the original file. It simply loads the JSON file into memory and opens a temporary file using the tempfile Python Package, finally once the operation is finished it performs an os.replace() to replace the original file (which is an atomic operation on Linux systems).

from json_storage_manager import atomic

with atomic.atomic_write(str(json_file)) as temp_file:
        with open(str(json_file)) as products_file:
            # get the JSON data into memory
            products_data = json.load(products_file)
        # now process the JSON data
        products_data.append(
            {'uuid': "2299d69e-deba-11e8-bded-680715cce955",
             'special_price': 111.0,
             'name': "Test Product"
             })
        json.dump(products_data, temp_file)

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

json_storage_manager-0.1.8.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

json_storage_manager-0.1.8-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file json_storage_manager-0.1.8.tar.gz.

File metadata

  • Download URL: json_storage_manager-0.1.8.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for json_storage_manager-0.1.8.tar.gz
Algorithm Hash digest
SHA256 913ea1dd02f013be39d9a02a048b4bc4557447a5dfbe73e4baa160a180b729d9
MD5 80b983203b7370f78c24323c2ade14bc
BLAKE2b-256 196273f77c3333b627f68dc5752e3a64118b523c4f3427e184f96decf2e4a50a

See more details on using hashes here.

File details

Details for the file json_storage_manager-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: json_storage_manager-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for json_storage_manager-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 07bdc6a5c0a5dfd913f8e0ad72976092bbb87e393187acba21795ce6a4bee59b
MD5 fe28a76fe4f15b7355968e98570be8ff
BLAKE2b-256 9781cb55465ed7aed8749fb727fef50a5d5a06054bddea9dd11b65bc6b8a1130

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