macro_rules! query_file_as {
($out_struct:path, $path:literal) => { ... };
($out_struct:path, $path:literal, $($args:tt)*) => { ... };
}Available on crate feature
macros only.Expand description
Compile-time checked SQL query read from a file, mapping to a named struct.
Combines query_file! and query_as!: the SQL lives in a separate
.sql file and rows are deserialised into the given struct.
ⓘ
struct UserReport {
name: String,
order_count: i64,
}
let reports = sqlx_mssql_odbc::query_file_as!(UserReport, "queries/user_reports.sql")
.fetch_all(&mut conn)
.await?;Requires the macros feature.