From 22d47efa9cb0c6ccff5e7567effba0e70854998f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 May 2020 09:38:41 +0200 Subject: [PATCH] Test database --- src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.rs b/src/main.rs index bd60380..8603a97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,14 @@ use comunic_server::data::config::{conf, Config}; use comunic_server::helpers::database; +use mysql::prelude::Queryable; + +#[derive(Debug, PartialEq, Eq)] +struct User { + id : i32, + name : String, + email: String, + age: i32 +} fn main() { @@ -9,5 +18,13 @@ fn main() { // Connect to the database database::connect(&conf().database).expect("Could not connect to database!"); + let mut conn = database::get_connection().unwrap(); + let res = conn.query_map("SELECT id, name, email, age FROM user", |(id, name, email, age)| { + User {id, name, email, age} + }).unwrap(); + println!("{:#?}", res); + + + println!("Hello, world!"); }