@@ -9,4 +9,19 @@ pub fn setup_clickhouse(path: &PathBuf) {
|
||||
} else {
|
||||
fs::create_dir_all(&path).expect("Failed to create directory");
|
||||
}
|
||||
|
||||
let path_str = path.to_str().unwrap();
|
||||
|
||||
let xml_content = format!(
|
||||
r#"<clickhouse>
|
||||
<user_defined_executable_functions_config>{path_str}/user_defined/*.xml</user_defined_executable_functions_config>
|
||||
<user_scripts_path>{path_str}/bin</user_scripts_path>
|
||||
<user_defined_path>{path_str}/user_defined</user_defined_path>
|
||||
</clickhouse>"#
|
||||
);
|
||||
|
||||
let config_path = path.join("config.xml");
|
||||
if !config_path.exists() {
|
||||
fs::write(config_path, xml_content).expect("Failed to write config file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
use crate::chdb::{arg::Arg, format, lib};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Mutex;
|
||||
use tauri::State;
|
||||
|
||||
use crate::AppState;
|
||||
use crate::{chdb, AppState};
|
||||
use String;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn query(query: String, state: State<'_, Mutex<AppState>>) -> Result<String, String> {
|
||||
let state = state.lock().unwrap();
|
||||
let config_path = state.clickhouse_dir.join("config.xml".to_string());
|
||||
|
||||
let args = vec![
|
||||
// Arg::LogLevel(chdb::log_level::LogLevel::Trace),
|
||||
Arg::OutputFormat(format::OutputFormat::JSON),
|
||||
Arg::Custom(
|
||||
"path".into(),
|
||||
Some(state.clickhouse_dir.display().to_string().into()),
|
||||
),
|
||||
Arg::ConfigFilePath(Cow::Borrowed(config_path.to_str().unwrap())),
|
||||
];
|
||||
|
||||
return match lib::execute(&query, Some(&args)) {
|
||||
|
||||
Reference in New Issue
Block a user