Create Database
This module provides database configuration and table creation functionality for the fleet management system using MariaDB.
Warning
Contains hardcoded credentials - consider using environment variables or configuration files in production environments.
- create_db.create_db(db_logger: Logger)[source]
Initialize database schema and create state vector table if not exists.
Performs the following operations: 1. Establishes database connection using configured credentials 2. Creates state_vector table with defined schema 3. Sets up proper indexing for common query patterns 4. Handles connection cleanup and error states
- Parameters:
db_logger (logging.Logger) – Configured logger instance for database operations
- Raises:
mariadb.Error – For database connection/execution errors
SystemExit – On fatal database connection failure
Example
Basic usage:
logger = logging.getLogger('DB') create_db(logger)
Note
Table Structure: - Stores real-time vehicle telemetry and status - Indexed on vehicle_id and time for temporal queries - Uses InnoDB engine for transaction support - UTF8mb4 encoding for full Unicode support