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.12.tar.gz (2.8 kB view hashes)

Uploaded Source

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