sql rust interaction file update

This commit is contained in:
2026-03-30 17:01:50 +02:00
parent 26cdc99701
commit b509c9f4c3

View File

@@ -14,39 +14,11 @@ impl DataBase {
self.connection.execute(arg).unwrap(); self.connection.execute(arg).unwrap();
} }
fn create_table(&self, table: String){ fn create_table(&self, table: String, var: String){
self.data_execute("CREATE TABLE ".to_owned() + &table + ";"); self.data_execute("CREATE TABLE ".to_owned() + &table + "(" + &var + ");");
} }
fn add_column(&self, table: String, arg: String){ fn add_column(&self, table: String, arg: String){
self.data_execute("ALTER TABLE ".to_owned() + &table + " ADD " + &arg + ";"); self.data_execute("ALTER TABLE ".to_owned() + &table + " ADD " + &arg + ";");
} }
} }
pub fn main() {
let db = DataBase::open(String::from("test"));
db.create_table("test".to_string());
db.add_column("test".to_string(), "name TEXT".to_string());
// println!("Hello, world!");
// let connection = sqlite::open("test.db").unwrap();
// let query = "
// CREATE TABLE users (name TEXT, age INTEGER);
// INSERT INTO users VALUES ('Alice', 42);
// INSERT INTO users VALUES ('Bob', 69);
// ";
// connection.execute(query).unwrap();
}
// struct User {
// name : string,
// level : int,
// }
// impl User {
// fn Create(&self){
// }
// }