Skip to main content

execute_with_formatter

Function execute_with_formatter 

Source
pub fn execute_with_formatter<'a, W: Write>(
    db: &Database,
    cmd: SqlCommand,
    batch_mode: &BatchMode,
    ui_mode: UiMode,
    writer: &mut W,
    output_format: OutputFormat,
    admin_launcher: Option<Box<dyn FnMut() -> Result<()> + 'a>>,
    limit: Option<usize>,
    quiet: bool,
) -> Result<()>
Expand description

Execute a SQL command with dynamic column detection.

This function creates formatters internally based on the query result type, ensuring that SELECT queries use the correct column headers.

§Output contract

  • --output json emits an array of per-statement result sets; a single statement yields a 1-element array. With --quiet, DDL/DML status result sets are omitted, so input consisting only of such statements yields an empty array.
  • Other formats emit one result block per statement, in statement order.

§Arguments

  • db - The database instance.
  • cmd - The SQL command to execute.
  • writer - The output writer.
  • output_format - The output format to use.
  • limit - Optional row limit.
  • quiet - Whether to suppress warnings and status result sets.