Mirror von
https://github.com/Chaoscaot/schemsearch
synchronisiert 2024-11-20 02:40:08 +01:00
Change MySQL Pool
Dieser Commit ist enthalten in:
Ursprung
916613773b
Commit
f567975d81
@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use sqlx::{Executor, MySql, MySqlPool, Pool, Row};
|
use sqlx::{ConnectOptions, Executor, MySql, MySqlPool, Pool, Row};
|
||||||
use sqlx::mysql::MySqlConnectOptions;
|
use sqlx::mysql::{MySqlConnectOptions, MySqlPoolOptions};
|
||||||
use crate::filter::SchematicFilter;
|
use crate::filter::SchematicFilter;
|
||||||
|
|
||||||
mod properties;
|
mod properties;
|
||||||
@ -34,14 +34,14 @@ pub async unsafe fn get_connection() {
|
|||||||
let mut conn = CONN.lock().unwrap();
|
let mut conn = CONN.lock().unwrap();
|
||||||
if conn.is_none() {
|
if conn.is_none() {
|
||||||
let properties = properties::load_mysql_properties();
|
let properties = properties::load_mysql_properties();
|
||||||
let _ = conn.insert(MySqlPool::connect_with(
|
let _ = conn.insert(MySqlPoolOptions::new()
|
||||||
MySqlConnectOptions::new()
|
.max_connections(5)
|
||||||
|
.connect_with(MySqlConnectOptions::new()
|
||||||
.host(properties.host.as_str())
|
.host(properties.host.as_str())
|
||||||
.port(3306)
|
.port(3306)
|
||||||
.username(properties.user.as_str())
|
.username(properties.user.as_str())
|
||||||
.password(properties.password.as_str())
|
.password(properties.password.as_str())
|
||||||
.database(properties.database.as_str())
|
.database(properties.database.as_str()))
|
||||||
)
|
|
||||||
.await.expect("Failed to connect to database"));
|
.await.expect("Failed to connect to database"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren