pub async fn execute_script_file(
file_path: &Path,
database: &Database,
output_config: &OutputConfig,
format: OutputFormat,
) -> Result<()>Expand description
Execute a CQL script file containing multiple statements
This function parses a CQL script file and executes each statement sequentially against the provided database. If any statement fails, execution stops immediately and an error is returned.
§Arguments
file_path- Path to the CQL script filedatabase- Database instance to execute statements againstoutput_config- Output configuration (color, pagination, etc.)format- Output format (table, json, csv, parquet)
§Returns
Ok(())- Script executed successfullyErr(_)- Error occurred during script parsing or execution
§Exit Code
On query execution errors, this function prints the error and exits with code 5 (as per M2_CLI_SPEC.md line 340).
§Examples
use std::path::Path;
use cqlite_core::Database;
use cqlite_cli::config::OutputConfig;
use cqlite_cli::cli::OutputFormat;
use cqlite_cli::script_executor::execute_script_file;
let db = Database::open(Path::new("test.db"), Default::default()).await?;
let config = OutputConfig::default();
execute_script_file(
Path::new("script.cql"),
&db,
&config,
OutputFormat::Table,
).await?;