Skip to main content

SCDB with json

Project description

Thanks for using quick-doc-py. If you like this project, you can support it on ko-fi. Your support helps improve the project and add new features. Thank you!

Description

This documentation explains how to use the db_system.py file, which contains classes and methods for handling JSON files with databases in a specifically designed manner.

Usage

Before using the db_system.py file, make sure you've installed the required dependencies. In this case, it only requires os and json modules.

import os
import json

To use the provided functionality, import the DataBase class from the db_system.py file:

from db_system import DataBase

Now you can utilize the various methods available for handling JSON files within the class (DataBase).

Methods

__init__(self, source_path: str) -> None:

This method initializes a new instance of the DataBase class with a given source_path where your JSON files are stored. It takes one mandatory parameter: source_path.

Example:

source_path = "C:/Users/huina/Python Projects/Important projects/Libs/db_py/pydb/data"
my_database = DataBase(source_path)

read(self, name: str) -> dict:

This method reads the content of a specified JSON file and returns it as a dictionary. It takes one mandatory parameter: name (the name of the JSON file without extension).

Example:

data = my_database.read("sample_file")

save(self, name: str, new_data: any) -> None:

This method saves a new dictionary or updates an existing one in a specified JSON file. It takes two mandatory parameters: name (the name of the JSON file without extension), and new_data (a new dictionary to be saved or updated).

Example:

my_database.save("sample_file", {"key": "value"})

add_element(self, name: str, key: any, data: dict):

This method adds a new element (specified by key) to an existing dictionary within the specified JSON file. The parameters include name (the name of the JSON file without extension), key (the identifier of the new element), and data (the data of the element to be added).

Example:

my_database.add_element("sample_file", "new_key", {"some_value": "example"})

edit_element(self, name: str, key: any, low_data: dict):

This method edits an existing element within a specified dictionary in the specified JSON file. It takes three mandatory parameters: name (the name of the JSON file without extension), key (the identifier of the element to be edited), and low_data (a dictionary with the new values to be updated).

Example:

my_database.edit_element("sample_file", "existing_key", {"some_key": "new_value"})

This documentation covers the basic usage of the db_system.py file and explains how you can use each method provided by the DataBase class. For full documentation, visit the official repository or contact the developers.

Created by quick-doc-py

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

pydb_vj-0.3.5.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

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

pydb_vj-0.3.5-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file pydb_vj-0.3.5.tar.gz.

File metadata

  • Download URL: pydb_vj-0.3.5.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Windows/11

File hashes

Hashes for pydb_vj-0.3.5.tar.gz
Algorithm Hash digest
SHA256 3a99ff6479c0083698a471b8a8dce87872aa65d4dc36a9cff4de09c9e9797da9
MD5 1739e5170cf91fbd30bc23bf7a929d28
BLAKE2b-256 1a81c103812d31357d12b3f32a54f149c31e4b80c6d65284c36774feae77e0c5

See more details on using hashes here.

File details

Details for the file pydb_vj-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: pydb_vj-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Windows/11

File hashes

Hashes for pydb_vj-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a2873ce8caa8fefa859d9fe4458e762c95445af459bc393603c49088f5d9e645
MD5 fd4942a3bad2f290804cdfd45039f590
BLAKE2b-256 60c0b7931d5946ba6f9dd710bebfb8d47fd6c9930c67b420229f23c9ccb7b5bf

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