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::*,
|
io::prelude::*,
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
error::Error,
|
error::Error,
|
||||||
sync::Arc,
|
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
@ -13,6 +12,7 @@ use sqlx::{
|
|||||||
sqlite::{
|
sqlite::{
|
||||||
SqliteConnection,
|
SqliteConnection,
|
||||||
SqliteConnectOptions,
|
SqliteConnectOptions,
|
||||||
|
SqliteQueryResult,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@ -56,14 +56,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
println!("{:?}", options);
|
println!("{:?}", config);
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
let sqlite_connection = Arc::new(
|
let mut sqlite_connection = RwLock::new(connect_sqlite(&config.database_path).await?);
|
||||||
RwLock::new(
|
|
||||||
connect_sqlite(&config.database_path).await?
|
#[cfg(feature = "sqlite")]
|
||||||
)
|
load_sqlite_template(sqlite_connection.get_mut()).await?;
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -78,8 +77,8 @@ async fn connect_sqlite(path: &PathBuf) -> sqlx::Result<SqliteConnection> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[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> {
|
fn get_config(options: &Options) -> std::io::Result<Config> {
|
||||||
|
Loading…
Reference in New Issue
Block a user