Skip to content

rusqlite first example does not compile #689

Open
@jlpoolen

Description

@jlpoolen
jlpoole@ryzdesk ~/adsb/tests/rust $ cargo new rusqlite1 --bin
     Created binary (application) `rusqlite1` package
jlpoole@ryzdesk ~/adsb/tests/rust $ cd rusqlite1/
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ cargo add rusqlite
    Updating crates.io index
      Adding rusqlite v0.30.0 to dependencies.
             Features:
             - array
             - backup
             - blob
             - buildtime_bindgen
             - bundled
             - bundled-full
             - bundled-sqlcipher
             - bundled-sqlcipher-vendored-openssl
             - bundled-windows
             - chrono
             - collation
             - column_decltype
             - csv
             - csvtab
             - extra_check
             - functions
             - hooks
             - i128_blob
             - in_gecko
             - limits
             - load_extension
             - loadable_extension
             - modern-full
             - modern_sqlite
             - release_memory
             - rusqlite-macros
             - serde_json
             - serialize
             - series
             - session
             - sqlcipher
             - time
             - trace
             - unlock_notify
             - url
             - uuid
             - vtab
             - wasm32-wasi-vfs
             - window
             - winsqlite3
             - with-asan
    Updating crates.io index
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ cat -n src/main.rs
     1  //
     2  // ref: https://rust-lang-nursery.github.io/rust-cookbook/database/sqlite.html
     3  //
     4  // cargo add rusqlite
     5  //
     6  use rusqlite::{Connection, Result};
     7  use rusqlite::NO_PARAMS;
     8
     9  fn main() -> Result<()> {
    10      let conn = Connection::open("cats.db")?;
    11
    12      conn.execute(
    13          "create table if not exists cat_colors (
    14               id integer primary key,
    15               name text not null unique
    16           )",
    17          NO_PARAMS,
    18      )?;
    19      conn.execute(
    20          "create table if not exists cats (
    21               id integer primary key,
    22               name text not null,
    23               color_id integer not null references cat_colors(id)
    24           )",
    25          NO_PARAMS,
    26      )?;
    27
    28      Ok(())
    29  }
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ date; cargo run
Tue Jan  2 05:35:08 PM PST 2024
   Compiling rusqlite1 v0.1.0 (/home/jlpoole/adsb/tests/rust/rusqlite1)
error[E0432]: unresolved import `rusqlite::NO_PARAMS`
 --> src/main.rs:7:5
  |
7 | use rusqlite::NO_PARAMS;
  |     ^^^^^^^^^^^^^^^^^^^ no `NO_PARAMS` in the root

For more information about this error, try `rustc --explain E0432`.
error: could not compile `rusqlite1` (bin "rusqlite1") due to previous error
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions