From 9e7d5ea424b6cca3ead1abe524fa5042c902200d Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 8 Mar 2023 22:01:06 +0100 Subject: [PATCH] Fixes --- schemsearch-cli/src/main.rs | 2 +- schemsearch-sql/src/lib.rs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/schemsearch-cli/src/main.rs b/schemsearch-cli/src/main.rs index cc08a61..1b9f953 100644 --- a/schemsearch-cli/src/main.rs +++ b/schemsearch-cli/src/main.rs @@ -169,7 +169,7 @@ fn main() { Some(x) => x }; - file = match std::fs::File::create(output_file_path) { + file = match File::create(output_file_path) { Ok(x) => Some(x), Err(e) => { cmd.error(ErrorKind::Io, format!("Error while creating output file: {}", e.to_string())).exit(); diff --git a/schemsearch-sql/src/lib.rs b/schemsearch-sql/src/lib.rs index 97729a6..a1133a6 100644 --- a/schemsearch-sql/src/lib.rs +++ b/schemsearch-sql/src/lib.rs @@ -1,6 +1,6 @@ use std::sync::Mutex; -use sqlx::{Executor, MySql, Pool, Row}; -use sqlx::mysql::MySqlPoolOptions; +use sqlx::{Executor, MySql, MySqlPool, Pool, Row}; +use sqlx::mysql::MySqlConnectOptions; mod properties; @@ -15,9 +15,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(MySqlPoolOptions::new() - .max_connections(5) - .connect(&format!("mysql://{}:{}@{}/{}", properties.user, properties.password, properties.host, properties.database)) + let _ = conn.insert(MySqlPool::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()) + ) .await.expect("Failed to connect to database")); } }