From a1bda53ca5c76d84c51838f56a0d4cc22c528e48 Mon Sep 17 00:00:00 2001 From: Jie Date: Thu, 26 Dec 2024 14:27:10 +0800 Subject: [PATCH] Exec function fail will retur error message now --- include/sqlConnection.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/sqlConnection.h b/include/sqlConnection.h index 64d69c0..40780a3 100644 --- a/include/sqlConnection.h +++ b/include/sqlConnection.h @@ -1,3 +1,4 @@ +#include #define DEBUG #ifdef DEBUG @@ -126,7 +127,6 @@ public: } std::expected>, std::string_view> Query(std::string_view command){ - //Not Implemented; std::vector> really_result; mysql_query(&mysql_client, command.data()); if(auto mysql_result = mysql_store_result(&mysql_client); mysql_result != nullptr){ @@ -152,9 +152,11 @@ public: return really_result; } - bool Execute(std::string_view command){ - //Not Implemented; - return false; + std::expected Execute(std::string_view command){ + auto res = mysql_query(&mysql_client, command.data()); + if(!res) + return std::unexpected(get_error_msg()); + return res; } std::vector get_tables(){