Cannot find 'execute' statement in rusqlite

This is a module, placed in the gedcom (rust-gedcom) library on Everything I've written up to this point is executable until it gets to the conn.execute statement. Where am I going wrong?

use rusqlite::{Connection, params};

pub fn dbstring(dbstr: String) {
    let conn = Connection::open("./glNG.db");

    match conn.execute(&dbstr, params![]) {
        Ok(updated) => println!("{} rows were updated by match", updated),
        Err(err) => println!("update failed: {}", err),



   Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `execute` found for enum `Result` in the current scope
   --> src/
6   |     match conn.execute(&dbstr, params![]) {
    |                ^^^^^^^ method not found in `Result<Connection, Error>`
note: the method `execute` exists on the type `Connection`
   --> /playground/.cargo/registry/src/
566 |     pub fn execute<P: Params>(&self, sql: &str, params: P) -> Result<usize> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider using `Result::expect` to unwrap the `Connection` value, panicking if the value is a `Result::Err`
6   |     match conn.expect("REASON").execute(&dbstr, params![]) {
    |               +++++++++++++++++

For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` due to previous error

The code is attempting run execute() on a Result, rather than the Connection.

Try this:

let conn = Connection::open("./glNG.db").expect("Unable to open database");
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.