Delete sql query not doing its job even though everything is correct
⚓ Rust 📅 2026-02-07 👤 surdeus 👁️ 1Hey, guys. Sorry to bother you all again, but I'm having an issue with my rust code at the moment.
I am making a wishlist program for myself at the moment, which can be used to turn a wishlist into something like this:
<!DOCTYPE html>
<html>
<head>
<title>Wishlist</title>
</head>
<body>
<h1>Wishlist</h1>
<hr>
<ol>
<li>Item 1</li>
<li>Item 2 <sup>[1]</sup></li>
<li>Item 3 <sup>[1]</sup><sup>[2]</sup></li>
</ol>
<h2>Notes</h2>
<hr>
<ol>
<li id="note1">Note 1</li>
<li id="note2">Note 2</li>
</ol>
</body>
</html>
Right now, I am having issues with dealing with note linking, in that I cannot say remove either note 1 or note 2 from either items two or three, even though my program creates the links just fine in the database backend, using rusqlite.
The code utilized to remove the linkis as follows:
pub fn remove_note_from_item(p: &str, item: &Item, note_id: u32) {
if let Ok(db) = Connection::open(&real_path(p)) {
let remove_link_statement = "DELETE FROM item_notes WHERE item_id = ?1 AND note_id = ?2";
if let Ok(mut statement) = db.prepare(remove_link_statement) {
if let Err(error) = statement.execute(params![item.id.clone(), note_id]) {
println!("{}", error);
}
}
}
}
If I were to run the query in SQLite directly, with the correct values, things work as they should, but not in the program itself.
As for where it the program this is called, it can be found here.
When I use the println! macro to step my way through things, it gets past the point where the statement is getting prepared and then is supposed to execute the query, but DB Browser shows no changes and I do not get any error reports.
Any ideas on how to fix this?
2 posts - 2 participants
🏷️ Rust_feed