experiments

All kinds of coding experiments
Log | Files | Refs | Submodules

main.rs (567B)


      1 use rusqlite::NO_PARAMS;
      2 use rusqlite::{Connection, Result};
      3 
      4 fn main() -> Result<()> {
      5     let conn = Connection::open("cats.db")?;
      6 
      7     conn.execute(
      8         "create table if not exists cat_colors (
      9              id integer primary key,
     10              name text not null unique
     11          )",
     12         NO_PARAMS,
     13     )?;
     14     conn.execute(
     15         "create table if not exists cats (
     16              id integer primary key,
     17              name text not null,
     18              color_id integer not null references cat_colors(id)
     19          )",
     20         NO_PARAMS,
     21     )?;
     22 
     23     Ok(())
     24 }