Module database

Module database 

Source
Expand description

Database operations for CeleRS CLI.

This module provides commands for managing database connections, health checks, and migrations. Currently supports PostgreSQL with planned support for MySQL.

§Features

  • Connection testing with latency benchmarks
  • Health monitoring and diagnostics
  • Connection pool statistics
  • Schema migrations (auto-migration via SQLx)

§Examples

use celers_cli::database;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Test database connection
    database::db_test_connection(
        "postgresql://user:pass@localhost/celers",
        false
    ).await?;

    // Check database health
    database::db_health("postgresql://user:pass@localhost/celers").await?;

    Ok(())
}

Functions§

db_health
Check database health with comprehensive diagnostics.
db_migrate
Run database migrations.
db_pool_stats
Show connection pool statistics.
db_test_connection
Test database connection with optional benchmarking.