Files
Projet_48h/backend/user.rs

24 lines
628 B
Rust

use sqlite::Connection;
pub struct DataBase {
connection: Connection,
}
impl DataBase {
pub fn open(name: String) -> DataBase {
let connection = sqlite::open(name + ".db").unwrap();
DataBase { connection }
}
fn data_execute(&self, arg: String){
self.connection.execute(arg).unwrap();
}
fn create_table(&self, table: String, var: String){
self.data_execute("CREATE TABLE ".to_owned() + &table + "(" + &var + ");");
}
fn add_column(&self, table: String, arg: String){
self.data_execute("ALTER TABLE ".to_owned() + &table + " ADD " + &arg + ";");
}
}