diff --git a/backend/user.rs b/backend/user.rs new file mode 100644 index 0000000..92e9b84 --- /dev/null +++ b/backend/user.rs @@ -0,0 +1,52 @@ +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){ + self.data_execute("CREATE TABLE ".to_owned() + &table + ";"); + } + + fn add_column(&self, table: String, arg: String){ + 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){ + +// } +// } \ No newline at end of file