Crates.io | serde-odbc |
lib.rs | serde-odbc |
version | 0.3.1 |
source | src |
created_at | 2018-02-25 20:39:00.40914 |
updated_at | 2024-02-11 20:57:34.796357 |
description | Bind serializable Rust data to ODBC statements |
homepage | |
repository | https://github.com/adamreichold/serde-odbc |
max_upload_size | |
id | 52824 |
size | 178,139 |
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();