diff --git a/src/database/sqlite/initialization.md b/src/database/sqlite/initialization.md index 24fdd4a8..1e957470 100644 --- a/src/database/sqlite/initialization.md +++ b/src/database/sqlite/initialization.md @@ -7,7 +7,7 @@ Use the `rusqlite` crate to open SQLite databases. See [`Connection::open`] will create the database if it doesn't already exist. -```rust,edition2018,no_run +```rust,edition2024,no_run use rusqlite::{Connection, Result}; fn main() -> Result<()> { @@ -18,7 +18,7 @@ fn main() -> Result<()> { id integer primary key, name text not null unique )", - [], + (), )?; conn.execute( "create table if not exists cats ( @@ -26,7 +26,7 @@ fn main() -> Result<()> { name text not null, color_id integer not null references cat_colors(id) )", - [], + (), )?; Ok(()) diff --git a/src/database/sqlite/insert_select.md b/src/database/sqlite/insert_select.md index 8e7e3395..30a7d9d9 100644 --- a/src/database/sqlite/insert_select.md +++ b/src/database/sqlite/insert_select.md @@ -5,7 +5,7 @@ [`Connection::open`] will open the database `cats` created in the earlier recipe. This recipe inserts data into `cat_colors` and `cats` tables using the [`execute`] method of `Connection`. First, the data is inserted into the `cat_colors` table. After a record for a color is inserted, [`last_insert_rowid`] method of `Connection` is used to get `id` of the last color inserted. This `id` is used while inserting data into the `cats` table. Then, the select query is prepared using the [`prepare`] method which gives a [`statement`] struct. Then, query is executed using [`query_map`] method of [`statement`]. -```rust,no_run +```rust,edition2024,no_run use rusqlite::{params, Connection, Result}; use std::collections::HashMap; @@ -51,7 +51,14 @@ fn main() -> Result<()> { })?; for cat in cats { - println!("Found cat {:?}", cat); + if let Ok(found_cat) = cat { + println!( + "Found cat {:?} {} is {}", + found_cat, + found_cat.name, + found_cat.color, + ); + } } Ok(()) diff --git a/src/database/sqlite/transactions.md b/src/database/sqlite/transactions.md index 3f80d8ea..22f1c6c4 100644 --- a/src/database/sqlite/transactions.md +++ b/src/database/sqlite/transactions.md @@ -12,7 +12,7 @@ a unique constraint on the color name. When an attempt to insert a duplicate color is made, the transaction rolls back. -```rust,edition2018,no_run +```rust,edition2024,no_run use rusqlite::{Connection, Result}; fn main() -> Result<()> {