pub fn update_write_dir(set_path: &str, dir_key: &str, dir_val: &str) -> rusqlite::Result<()> {
    // Collect the directory values
    let mut dir = std::collections::HashMap::new();
    dir.insert(dir_key, dir_val);

    // Establish a connection to the database
    let conn = Connection::open(&set_path)?;

    let mut stmt = conn.prepare("select path from directories where option = (?1)")?;
    let mut rows = stmt.query(params![&dir_key])?;

    let mut num_match = 0;

    while let Some(_rows) = rows.next()? {
        num_match += 1;
    }
    if num_match != 0 {
        // Insert the values into the table
        for (key, val) in &dir {
            conn.execute(
                "update directories set path = (?2)
                where option = (?1)",
                &[&key.to_string(), &val.to_string()],
            )?;
        }
    } else if num_match == 0 {
        conn.execute(
            "insert into directories (option, path) values (?1, ?2)",
            &[&dir_key.to_string(), &dir_val.to_string()],
        )?;
    }
    // return an Ok value
    Ok(())
}
/// Function that updates the directory in the database
Function that updates the directory in the database
Function that updates the directory in the database
pub fn update_write_dir(set_path: &str, dir_key: &str, dir_val: &str) -> rusqlite::Result<()> {
    // Collect the directory values
    let mut dir = std::collections::HashMap::new();
    dir.insert(dir_key, dir_val);
    // Establish a connection to the database
    let conn = Connection::open(&set_path)?;
    let mut stmt = conn.prepare("select path from directories where option = (?1)")?;
    let mut rows = stmt.query(params![&dir_key])?;
    let mut num_match = 0;
    while let Some(_rows) = rows.next()? {
        num_match += 1;
    }
    if num_match != 0 {
        // Insert the values into the table
        for (key, val) in &dir {
            conn.execute(
                "update directories set path = (?2)
                where option = (?1)",
                &[&key.to_string(), &val.to_string()],
            )?;
        }
    } else if num_match == 0 {
        conn.execute(
            "insert into directories (option, path) values (?1, ?2)",
            &[&dir_key.to_string(), &dir_val.to_string()],
        )?;
    }
    // return an Ok value
    Ok(())
}
pub fn update_write_dir ( set_path : & str , dir_key : & str , dir_val : & str ) -> rusqlite :: Result < ( ) > { // Collect the directory values let mut dir = std :: collections :: HashMap :: new ( ) ; dir . insert ( dir_key , dir_val ) ; // Establish a connection to the database let conn = Connection :: open ( & set_path ) ? ; let mut stmt = conn . prepare ( " " ) ? ; let mut rows = stmt . query ( params ! [ dir_key ] ) ? ; let mut num_match = 0 ; while let Some ( _rows ) = rows . next ( ) ? { num_match += 1 ; } if num_match != 0 { // Insert the values into the table for ( key , val ) in & dir { conn . execute ( " " , & [ & key . to_string ( ) , & val . to_string ( ) ] , ) ? ; } } else if num_match == 0 { conn . execute ( " " , & [ & dir_key . to_string ( ) , & dir_val . to_string ( ) ] , ) ? ; } // return an Ok value Ok ( ( ) ) }
Function that updates the directory in the database
Function that updates the directory in the database
set_path
&str
dir_key
&str
dir_val
&str
set_path
&str
dir_key
&str
dir_val
&str