From 55557b604b89148b1e0adadb6aeed6c09ad8f8df Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 4 Oct 2021 12:35:44 +0000 Subject: [PATCH] Fix merge Issues --- src/main.rs | 9 +++++---- src/sqlite/mod.rs | 17 ++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 129a95f..4233a2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,7 @@ use std::{ boxed::Box, error::Error, }; -use crate::{ - cli::Options, - config::Config, -}; +use crate::{cli::Options, config::Config, sqlite::sqlite_out}; mod cli; @@ -42,6 +39,10 @@ async fn main() -> Result<(), Box> { #[cfg(feature = "sqlite")] sqlite::load_template(&sqlite_connection).await?; + sqlite::add_test_user(&sqlite_connection).await?; + println!("{}" ,sqlite::sqlite_out(&sqlite_connection, "SELECT * FROM users;", 1).await?); + + net::web(sqlite_connection).await; Ok(()) diff --git a/src/sqlite/mod.rs b/src/sqlite/mod.rs index 694bc6d..b336b53 100644 --- a/src/sqlite/mod.rs +++ b/src/sqlite/mod.rs @@ -1,9 +1,12 @@ use std::path::PathBuf; -use sqlx::sqlite::{ - SqlitePool, - SqliteConnectOptions, - SqliteQueryResult, - SqliteSynchronous, +use sqlx::{ + sqlite::{ + SqlitePool, + SqliteConnectOptions, + SqliteQueryResult, + SqliteSynchronous, + }, + Row, }; /// Prepare sqlite database connection @@ -27,11 +30,11 @@ pub async fn load_template(sqlite_handle: &SqlitePool) -> sqlx::Result sqlx::Result{ +pub async fn add_test_user(sqlite_handle: & SqlitePool)-> sqlx::Result{ sqlx::query("insert into users values('1923123','Elierik','erikeli',1,2,3);").execute(sqlite_handle).await } -pub async fn sqlite_out(sqlite_handle: &mut SqliteConnection, query:&str, index:usize) -> Result { +pub async fn sqlite_out(sqlite_handle: &SqlitePool, query:&str, index:usize) -> Result { sqlx::query(query).fetch_one(sqlite_handle).await.unwrap().try_get(index) }