Core¶
A file that containing the main implementation of the LightDB database management system
- class lightdb.core.LightDB(location: str)[source]¶
Bases:
dictLight Database¶
A lightweight database implemented as a dictionary with JSON file storage.
This class extends the built-in Python dict class to provide a simple and easy-to-use key-value store that persists its data in a JSON file. The class provides methods to set, get, and remove individual key-value pairs.
- classmethod current() LightDB[source]¶
Returns the current instance of the LightDB class
- Returns:
LightDB: An initialized instance of the LightDB
- get(key: str) _VT | _T[source]¶
- get(key: str, default: _VT | _T) _VT | _T
Get the value associated with a key from the database
- Params:
key (
str): The key to retrievedefault (
Any, optional): The default value to return if the key doesn`t exist- Returns:
_VT|_T: The value associated with the key, or the default value if the key doesn`t exist