db package
create_database module
Database creator.
This script creates the database on the user’s local machine at its (script’s) location. It checks if the database exists before creating a new one.
Also, populates the database with dummy data that were captured from a real device.
- rfserver.db.create_database.create_db() None
Creates the database (sqlite3) on the user’s local machine. After creating the database with the tables, it calls the populate_db() function.
- rfserver.db.create_database.populate_db() None
Populates the database that wase created by the create_db() function with dummy data. Dummy data were captured by a real device so the database can simulate real cases.
database module
Database connector with searching capabilties.
This module contains a class that tries to connect to the database, if the database was missing it will call the create_db() function to create one. It also provides a method to search inside the database for a specific range of the data.
- class rfserver.db.database.DetailDataBaseManager
Bases:
objectConnect to the database. Call the create_db() to create one if database not found.
- db_detail_path = '/home/docs/checkouts/readthedocs.org/user_builds/rf-analysis-engine/checkouts/latest/src/rfserver/db/detail.db'
- classmethod search_power_frequency(min_power: float, max_power: float, min_frequency: float, max_frequency: float) list[tuple[int, float, float, str]]
Fetch data readings from the database within a power and frequency range.
- Parameters:
min_power (float) – The minimum power in the range.
max_power (float) – The maximum power in the range.
min_frequency (float) – The minimum frequency in the range.
max_frequency (float) – The maximum frequency in the range.
- Returns:
- A list of tuples, were each tuple contains:
int: Record ID.
float: Power value.
float: Frequency value.
str: Timestamp of the reading.
- Return type:
list
Example
>>> from database import DetialDataBaseManager >>> DetialDataBaseManager.search_power_frequency(20.12, 20.54, 103.7, 105.1) >>> [(90, 103.7, 20.54, '06-06-2025 12:16:18'), (91, 104.3, 20.18, '06-06-2025 12:16:18')]