Add sqlite template insertion for users.sql
This commit is contained in:
parent
59d26277db
commit
c42fbebe09
17
src/main.rs
17
src/main.rs
@ -5,7 +5,6 @@ use std::{
|
||||
io::prelude::*,
|
||||
boxed::Box,
|
||||
error::Error,
|
||||
sync::Arc,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use sqlx::{
|
||||
@ -13,6 +12,7 @@ use sqlx::{
|
||||
sqlite::{
|
||||
SqliteConnection,
|
||||
SqliteConnectOptions,
|
||||
SqliteQueryResult,
|
||||
},
|
||||
};
|
||||
use tokio::{
|
||||
@ -56,14 +56,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
println!("{:?}", options);
|
||||
println!("{:?}", config);
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
let sqlite_connection = Arc::new(
|
||||
RwLock::new(
|
||||
connect_sqlite(&config.database_path).await?
|
||||
)
|
||||
);
|
||||
let mut sqlite_connection = RwLock::new(connect_sqlite(&config.database_path).await?);
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
load_sqlite_template(sqlite_connection.get_mut()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -78,8 +77,8 @@ async fn connect_sqlite(path: &PathBuf) -> sqlx::Result<SqliteConnection> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
async fn load_sqlite_template(){
|
||||
|
||||
async fn load_sqlite_template(sqlite_handle: &mut SqliteConnection) -> sqlx::Result<SqliteQueryResult> {
|
||||
sqlx::query(include_str!("sqlite/users.sql")).execute(sqlite_handle).await
|
||||
}
|
||||
|
||||
fn get_config(options: &Options) -> std::io::Result<Config> {
|
||||
|
Loading…
Reference in New Issue
Block a user