mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 21:39:21 +00:00
Test database
This commit is contained in:
parent
cf7bf3e14f
commit
22d47efa9c
17
src/main.rs
17
src/main.rs
@ -1,5 +1,14 @@
|
|||||||
use comunic_server::data::config::{conf, Config};
|
use comunic_server::data::config::{conf, Config};
|
||||||
use comunic_server::helpers::database;
|
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() {
|
fn main() {
|
||||||
|
|
||||||
@ -9,5 +18,13 @@ fn main() {
|
|||||||
// Connect to the database
|
// Connect to the database
|
||||||
database::connect(&conf().database).expect("Could not connect to 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!");
|
println!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user