Questions tagged [rusqlite]
27 questions
7
votes
1 answer
How do we use SELECT query with an external WHERE parameter in rusqlite?
I need to fetch a row from a database using SELECT and WHERE, I need to fetch a row depending on the age, I tried this way using some other tutorial.
use rusqlite::{params, Connection, Result};
#[derive(Debug)]
struct Person {
id: i32,
…

Eka
- 14,170
- 38
- 128
- 212
6
votes
1 answer
How to insert and fetch date in a sqlite database using rusqlite?
I have a struct with NaiveDate field and I want to insert this field to a table. This is my whole code
use chrono::naive::NaiveDate;
use rusqlite::{params, Connection, Result};
#[derive(Debug)]
struct Person {
id: i32,
name: String,
…

Eka
- 14,170
- 38
- 128
- 212
6
votes
1 answer
Rusqlite insert multiple rows
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…

Simen Russnes
- 2,002
- 2
- 26
- 56
5
votes
1 answer
How to use SQLite via rusqlite from multiple threads?
There are a number of articles explaining the problem of multi-threaded access with SQLite but I couldn't find any easy solutions. How does one access SQLite from e.g. a web server where multiple threads work concurrently?
Sources (that still don't…

VasiliNovikov
- 9,681
- 4
- 44
- 62
3
votes
0 answers
How to bundle a Gtk-rs and rusqlite program for Windows from Linux?
I have a Rust program that depends on libgtk3 and sqlite3 and I would like to generate an installer/executable for x86 Windows. I do not have access to a Windows machine so I need to bundle it from my primary development platform, x86 Linux.
How…

noconst
- 639
- 4
- 15
2
votes
2 answers
Replace strings with "null" value as real null values rusqlite
I need to convert strings that have the value null to actual null values in a SQLite DB using rusqlite. I'm not in control of these string values. I've found the Null struct, but I'm not sure how to concisely pass it as a parameter, but then use the…

Jack
- 1,893
- 1
- 11
- 28
2
votes
1 answer
Rust rusqlite cannot insert row
The following code fails to compile with:
55 | (":dataset_id", &dataset_id),
| ^^^^^^^^^^^ expected `u32`, found `i32`
pub fn save(&mut self, annotations: Vec, dataset_id: i32) ->…

Beebunny
- 4,190
- 4
- 24
- 37
2
votes
1 answer
the trait `rusqlite::types::to_sql::ToSql` is not implemented for `serde_json::value::Value`
I'm trying to serialise JSON values from a serde_json::Map into a SQLite database. I would like to use multiple data types in the Map and have them converted into the appropriate SQLite datatypes.
The map is created in collect_values and is passed…

not_a_developer
- 23
- 3
1
vote
0 answers
bus error on usage of rusqlite with spatialite extension
I'm seeing a bus error on cargo run when attempting to load the spatialite extension with rusqlite:
Finished dev [unoptimized + debuginfo] target(s) in 1.19s
Running `target/debug/rust-spatialite-example`
[1] 33253 bus error cargo run…

Seth Vincent
- 174
- 7
1
vote
1 answer
Linker error when cross compiling for raspberry pi
I try to cross-compile a simple rust program with sqlite on Linux for raspberry pi:
Cargo.toml
...
[dependencies]
rusqlite = { version = "0.26.3", features = ["bundled"] }
.cargo/config
[target.arm-unknown-linux-gnueabihf]
linker =…

Johannes Braun
- 65
- 6
1
vote
1 answer
What's the idiomatic way to pass types in Rust?
I create a connection type, i.e.
let mut conn = Connection::open("sqlite.db").unwrap();
And then I pass that type to my save_all function along with a vector, like this:
pub fn save_all(conn: &mut Connection,
vehicles: Vec)…

Beebunny
- 4,190
- 4
- 24
- 37
1
vote
1 answer
rusqlite returns Err(InvalidParameterCount(1, 0))
I try to execute a simple sqlite statement with rusqlite but get an error everytime.
let seconds = 1;
conn.execute(
"DELETE FROM session WHERE created < DATETIME('now', '?1 seconds')",
params![seconds],
)?;
returns an…

secana
- 671
- 6
- 15
0
votes
0 answers
Rust RwLock Object with function that moves self
I am using https://github.com/rusqlite/rusqlite to interface rust with SQLite. I have an object of type Connection. This connection is held behind a RwLock since the threadsafety mode of SQLite I'm using only guarantees inter-process threadsafety.…

Folling
- 415
- 3
- 12
0
votes
2 answers
Using the rusqlite crate, can I pass an array as a parameter for a clause containing 'IN'?
I am using the rusqlite crate in Rust to perform SQL queries on an SQLite database. I have a query that needs to filter rows based on a list of values using the IN clause. I would like to know if there is a way to pass an array or a vector as a…

Felipe
- 16,649
- 11
- 68
- 92
0
votes
0 answers
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1 | rust compilation error
On a windows 11 machine. I ran cargo build and received this error:
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
I am using `rusqlite:"0.29.0", and this is my tomo file
[package]
name = "backend-rust"
version = "0.1.0"
edition…