[Fix] Small omega, complete DB controll
This commit is contained in:
parent
ad334481b1
commit
d868002e8d
3 changed files with 323 additions and 306 deletions
618
Cargo.lock
generated
618
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "Omega"
|
name = "omega"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,11 @@ use crate::sql::{
|
||||||
static SQL_DB: Lazy<Arc<RwLock<Option<Pool<MySql>>>>> = Lazy::new(|| Arc::new(RwLock::new(None)));
|
static SQL_DB: Lazy<Arc<RwLock<Option<Pool<MySql>>>>> = Lazy::new(|| Arc::new(RwLock::new(None)));
|
||||||
|
|
||||||
pub async fn connect() -> Result<Pool<MySql>, sqlx::Error> {
|
pub async fn connect() -> Result<Pool<MySql>, sqlx::Error> {
|
||||||
let user = env::var("DB_USERNAME").expect("DB_USERNAME is not set");
|
let url = env::var("DB_URL").expect("DB_URL is not set");
|
||||||
let passwd = env::var("DB_PASSWD").expect("DB_PASSWD is not set");
|
|
||||||
let table = env::var("DB_TABLE").expect("DB_TABLE is not set");
|
|
||||||
|
|
||||||
MySqlPoolOptions::new()
|
MySqlPoolOptions::new()
|
||||||
.max_connections(200)
|
.max_connections(200)
|
||||||
.connect(&format!(
|
.connect(&url)
|
||||||
"mysql://{}:{}@127.0.0.1:3306/{}",
|
|
||||||
user, passwd, table
|
|
||||||
))
|
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
// Omega
|
// Omega
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue