8 releases

0.3.1 Feb 11, 2024
0.3.0 Dec 25, 2019
0.2.0 Dec 21, 2019
0.1.4 Apr 23, 2019
0.1.0 Feb 25, 2018

#21 in #odbc

34 downloads per month

LGPL-3.0

45KB
1K SLoC

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();

Dependencies

~0.7–1.3MB
~29K SLoC