Compare commits
2 Commits
999d27936a
...
e77fb7cb1e
| Author | SHA1 | Date | |
|---|---|---|---|
| e77fb7cb1e | |||
| 4c1a439319 |
@@ -10,15 +10,22 @@ impl DataBase {
|
||||
DataBase { connection }
|
||||
}
|
||||
|
||||
fn data_execute(&self, arg: String){
|
||||
self.connection.execute(arg).unwrap();
|
||||
pub fn data_execute(&self, arg: String){
|
||||
match self.connection.execute(arg){
|
||||
OK => println!("Ok"),
|
||||
Err(e) => panic!("Error : {}",e),
|
||||
}
|
||||
}
|
||||
|
||||
fn create_table(&self, table: String, var: String){
|
||||
self.data_execute("CREATE TABLE ".to_owned() + &table + "(" + &var + ");");
|
||||
pub fn create_table(&self, table: &str, var: &str){
|
||||
self.data_execute("CREATE TABLE ".to_owned() + &table.to_string() + "(" + &var.to_string() + ");");
|
||||
}
|
||||
|
||||
fn add_column(&self, table: String, arg: String){
|
||||
self.data_execute("ALTER TABLE ".to_owned() + &table + " ADD " + &arg + ";");
|
||||
pub fn add_column(&self, table: &str, arg: &str){
|
||||
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