database
dev_tool.db.sqlite.database
log = logging.getLogger(__name__)
module-attribute
SQLiteDatabase
A class for SQLite database operations.
This class provides methods for managing SQLite database connections and performing CRUD operations on destruction schedules.
The constructor for the SQLiteDatabase class.
Parameters:
-
path(Path | None, default:None) –The path to the SQLite database file, defaults to application database.
Source code in dev_tool/db/sqlite/database.py
path = path or STRATUS / 'dev_tool.db'
instance-attribute
get_connection
A context manager that provides a SQLite database connection.
:yield: A SQLite database connection.
Source code in dev_tool/db/sqlite/database.py
add_schedule
A method that adds or updates a destruction schedule.
Parameters:
-
name(str) –The name of the schedule entry.
-
destructing_at(float) –The timestamp when destruction should occur.
Raises:
-
SQLiteConnectionError–If schedule addition fails.
Source code in dev_tool/db/sqlite/database.py
get_schedules
A method that retrieves all destruction schedules.
Returns:
Raises:
-
SQLiteConnectionError–If schedule retrieval fails.
Source code in dev_tool/db/sqlite/database.py
remove_schedule
A method that removes a destruction schedule by name.
Parameters:
-
name(str) –The name of the schedule to remove.
Raises:
-
SQLiteConnectionError–If schedule removal fails.
Source code in dev_tool/db/sqlite/database.py
time_remaining
A method that calculates the remaining time before destruction.
Parameters:
-
name(str) –The name of the schedule to check.
Returns:
-
float | None–The remaining time in seconds, or None if schedule doesn't exist or expired.
Raises:
-
SQLiteConnectionError–If time calculation fails.