init serv file

This commit is contained in:
2025-08-13 22:07:41 +08:00
parent 3747a2c65e
commit e0492e1d74
33 changed files with 4108 additions and 168 deletions

View File

@@ -0,0 +1,14 @@
use actix_web::web;
use actix_web::web::Data;
use r2d2::{Pool, State};
use r2d2_sqlite::SqliteConnectionManager;
pub struct SqliteState {
pool: Pool<SqliteConnectionManager>,
}
pub fn init_database() -> Data<SqliteState> {
let db = SqliteConnectionManager::file("./database.mod");
let pool = Pool::new(db).unwrap();
Data::new(SqliteState { pool: pool.clone() })
}