Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-689 updated rusqlite to use () for no params #708

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/database/sqlite/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -18,15 +18,15 @@ fn main() -> Result<()> {
id integer primary key,
name text not null unique
)",
[],
(),
)?;
conn.execute(
"create table if not exists cats (
id integer primary key,
name text not null,
color_id integer not null references cat_colors(id)
)",
[],
(),
)?;

Ok(())
Expand Down
11 changes: 9 additions & 2 deletions src/database/sqlite/insert_select.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion src/database/sqlite/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down