Fix merge Issues

This commit is contained in:
Erik Foris 2021-10-04 12:35:44 +00:00
parent b8a12fcd42
commit 55557b604b
2 changed files with 15 additions and 11 deletions

View File

@ -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<dyn Error>> {
#[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(())

View File

@ -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<SqliteQue
)).execute(sqlite_handle).await
}
pub async fn add_test_user(sqlite_handle: &mut SqliteConnection)-> sqlx::Result<SqliteQueryResult>{
pub async fn add_test_user(sqlite_handle: & SqlitePool)-> sqlx::Result<SqliteQueryResult>{
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<String, sqlx::Error> {
pub async fn sqlite_out(sqlite_handle: &SqlitePool, query:&str, index:usize) -> Result<String, sqlx::Error> {
sqlx::query(query).fetch_one(sqlite_handle).await.unwrap().try_get(index)
}