Skip to main content

query_file

Macro query_file 

Source
macro_rules! query_file {
    ($path:literal) => { ... };
    ($path:literal, $($args:tt)*) => { ... };
}
Available on crate feature macros only.
Expand description

Compile-time checked SQL query read from a file at compile time.

The file path is relative to the crate root. This keeps large queries out of your Rust source files.

let reports = sqlx_mssql_odbc::query_file!("queries/monthly_report.sql")
    .fetch_all(&mut conn)
    .await?;

Requires the macros feature.