Macro sqlx::query_file_as[][src]

macro_rules! query_file_as {
    ($out_struct:path, $path:literal) => { ... };
    ($out_struct:path, $path:literal, $($args:tt)*) => { ... };
}
This is supported on crate feature macros only.

Combines the syntaxes of query_as! and query_file!.

Enforces requirements of both macros; see them for details.

ⓘ
#[derive(Debug)]
struct Account {
    id: i32,
    name: String
}

// let mut conn = <impl sqlx::Executor>;
let account = sqlx::query_file_as!(Account, "tests/test-query-account-by-id.sql", 1i32)
    .fetch_one(&mut conn)
    .await?;

println!("{:?}", account);
println!("{}: {}", account.id, account.name);