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
Release files for pydb-vj 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydb_vj-0.3.7.tar.gz | 2.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydb_vj-0.3.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.8 kB
Release files / pydb_vj-0.3.7.tar.gz
| Download URL | pydb_vj-0.3.7.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a19d81afbb8f2f928f7b766e6694cb344229e14bf4a6898f91f770a80a771919
|
|
BLAKE2b-256 checksum How to use checksums |
d5125015afa1511823a3aa6fb961fbc344114d92c5ffc45f9b90efb8e895cc70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Windows/11
|
Release files / pydb_vj-0.3.7-py3-none-any.whl
| Download URL | pydb_vj-0.3.7-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f09753b573519070a1c98f9b48afc3f51373501903baf26dd96a10bede4b69d5
|
|
BLAKE2b-256 checksum How to use checksums |
c73afde1ce271b8ab404851ba5c8831f193017cdce7fcb62373069974e583cf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.8 Windows/11
|