use rusqlite::{Connection, Result};
      use rusqlite::NO_PARAMS;
      
      fn main() -> Result<()> {
        let conn = Connection::open("cats.db")?;
        conn.execute(
          "create table if not exists cat_colors (
          id integer primary key,
          name text not null unique
          )",
          NO_PARAMS,
        )?;
        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)
          )",
          NO_PARAMS,
        )?;
        Ok(())
      }
      

      Rust language logo
      Create SQlite database

      Codiga's Rust Recipes

      database with rusqlite

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.