update and add insert command in user.rs file

This commit is contained in:
2026-03-31 09:22:43 +02:00
parent b509c9f4c3
commit 4c1a439319

View File

@@ -10,15 +10,22 @@ impl DataBase {
DataBase { connection } DataBase { connection }
} }
fn data_execute(&self, arg: String){ pub fn data_execute(&self, arg: String){
self.connection.execute(arg).unwrap(); match self.connection.execute(arg){
OK => println!("Ok"),
Err(e) => panic!("Error : {}",e),
}
} }
fn create_table(&self, table: String, var: String){ pub fn create_table(&self, table: &str, var: &str){
self.data_execute("CREATE TABLE ".to_owned() + &table + "(" + &var + ");"); self.data_execute("CREATE TABLE ".to_owned() + &table.to_string() + "(" + &var.to_string() + ");");
} }
fn add_column(&self, table: String, arg: String){ pub fn add_column(&self, table: &str, arg: &str){
self.data_execute("ALTER TABLE ".to_owned() + &table + " ADD " + &arg + ";"); self.data_execute("ALTER TABLE ".to_owned() + &table.to_string() + " ADD " + &arg.to_string() + ";");
}
pub fn insert(&self, table: &str, arg: &str){
self.data_execute("INSERT INTO ".to_owned() + &table.to_string() + " VALUES (" + &arg.to_string() + ")" + ";");
} }
} }