From f567975d81321a62d51d1e3f0177fbc9918b6edf Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 12 Mar 2023 14:24:40 +0100 Subject: [PATCH] Change MySQL Pool --- schemsearch-sql/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/schemsearch-sql/src/lib.rs b/schemsearch-sql/src/lib.rs index e99f2e1..33e41b1 100644 --- a/schemsearch-sql/src/lib.rs +++ b/schemsearch-sql/src/lib.rs @@ -16,8 +16,8 @@ */ use std::sync::Mutex; -use sqlx::{Executor, MySql, MySqlPool, Pool, Row}; -use sqlx::mysql::MySqlConnectOptions; +use sqlx::{ConnectOptions, Executor, MySql, MySqlPool, Pool, Row}; +use sqlx::mysql::{MySqlConnectOptions, MySqlPoolOptions}; use crate::filter::SchematicFilter; mod properties; @@ -34,14 +34,14 @@ pub async unsafe fn get_connection() { let mut conn = CONN.lock().unwrap(); if conn.is_none() { let properties = properties::load_mysql_properties(); - let _ = conn.insert(MySqlPool::connect_with( - MySqlConnectOptions::new() + let _ = conn.insert(MySqlPoolOptions::new() + .max_connections(5) + .connect_with(MySqlConnectOptions::new() .host(properties.host.as_str()) .port(3306) .username(properties.user.as_str()) .password(properties.password.as_str()) - .database(properties.database.as_str()) - ) + .database(properties.database.as_str())) .await.expect("Failed to connect to database")); } }