Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 930 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 930 Bytes

Build Status

Bind serializable Rust data to ODBC statements

The main function of this crate is to use the Serialize trait to automatically make the necessary calls to SQLBindCol and SQLBindParameter. It also supports binding of parameter and row sets, e.g. the following code performs a bulk insert:

#[derive(Clone, Default, Serialize)]
struct Todo {
    id: serde_odbc::Nullable<i32>,
    text: serde_odbc::String<generic_array::typenum::U4096>,
    done: bool,
}

let stmt: serde_odbc::Statement<serde_odbc::ParamSet<Todo>, serde_odbc::NoCols> =
    serde_odbc::Statement::new(&conn, "INSERT INTO todos (id, text, done) VALUES (?, ?, ?)");

stmt.params().reserve(128);
for todo in /* ... */ {
    stmt.params().push(todo);
}

stmt.exec().unwrap();