Split server in smaller modules
This commit is contained in:
33
src/utils/md_helpers.cpp
Normal file
33
src/utils/md_helpers.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "utils/md_helpers.hpp"
|
||||
|
||||
#include <duckdb.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace duckdb {
|
||||
std::string GetMDToken(Connection &connection) {
|
||||
auto query_res = connection.Query("CALL GET_MD_TOKEN()");
|
||||
if (query_res->HasError()) {
|
||||
query_res->ThrowError();
|
||||
return ""; // unreachable
|
||||
}
|
||||
|
||||
auto chunk = query_res->Fetch();
|
||||
return chunk->GetValue(0, 0).GetValue<std::string>();
|
||||
}
|
||||
|
||||
bool IsMDConnected(Connection &con) {
|
||||
if (!con.context->db->ExtensionIsLoaded("motherduck")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto query_res = con.Query("CALL MD_IS_CONNECTED()");
|
||||
if (query_res->HasError()) {
|
||||
std::cerr << "Error in IsMDConnected: " << query_res->GetError()
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto chunk = query_res->Fetch();
|
||||
return chunk->GetValue(0, 0).GetValue<bool>();
|
||||
}
|
||||
} // namespace duckdb
|
||||
Reference in New Issue
Block a user