How can I insert multiple rows in a single query using rusqlite? Looking at the syntax below, I think it fails because the query expects there to be only one value in the Vec.
Can it be done with any kind of helper function, or would I have to create the query in its entirety?
let mut names = Vec::new();
names.push("Mittens");
names.push("Jingle Paws");
names.push("Sir Fluffy");
match conn.execute(
"INSERT INTO cats (name) VALUES (?1)",
names,
) {
Ok(_t) => (),
Err(e) => {
let gil = Python::acquire_gil();
let py = gil.python();
let error_message = format!("Error inserting cats into database! {}", e.to_string());
PyIOError::new_err(error_message).restore(py);
return Err(PyErr::fetch(py));
}
};
?
OSError: Error inserting cats into database! Wrong number of parameters passed to query. Got 2, needed 1