update and add insert command in user.rs file
This commit is contained in:
@@ -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() + ")" + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user