Expand description
SQLModel Console - Beautiful terminal output for SQLModel Rust.
sqlmodel-console is the optional UX layer for SQLModel Rust. It renders
errors, query results, schema trees, and progress in a way that adapts to
humans (rich formatting) or agents/CI (plain or JSON).
§Role In The Architecture
- Optional integration: enabled via the
consolefeature insqlmodelor in driver crates. - Agent-safe output: auto-detects AI coding tools and switches to plain text.
- Diagnostics: provides structured renderables for tables, errors, and status.
This crate provides styled console output that automatically adapts to the terminal environment. When running under an AI coding agent, output is plain text. When running interactively, output is richly formatted.
§Features
rich- Enable rich formatted output with colors, tables, panelssyntax- Enable SQL syntax highlighting (requiresrich)full- Enable all features
§Output Mode Detection
The crate automatically detects the appropriate output mode:
- Plain: AI agents (Claude Code, Codex, etc.), CI systems, piped output
- Rich: Interactive human terminal sessions
- Json: Structured output for tool integrations
You can override detection via environment variables:
SQLMODEL_PLAIN=1- Force plain text outputSQLMODEL_RICH=1- Force rich output (even for agents)SQLMODEL_JSON=1- Force JSON structured output
§Example
use sqlmodel_console::OutputMode;
let mode = OutputMode::detect();
if mode.supports_ansi() {
println!("Rich formatting available!");
} else {
println!("Plain text mode");
}Re-exports§
pub use console::SqlModelConsole;pub use mode::OutputMode;pub use theme::Theme;pub use traits::ConsoleAware;
Modules§
- console
- SqlModelConsole - Main coordinator for console output.
- logging
- Logging infrastructure for sqlmodel-console.
- mode
- Output mode detection for agent-safe console output.
- prelude
- Prelude for convenient imports.
- renderables
- SQLModel-specific renderables.
- theme
- Theme definitions for SQLModel console output.
- traits
- Traits for console-aware components.
- widgets
- Progress indicators and interactive widgets.