update
This commit is contained in:
parent
eb68d42748
commit
97d7206559
8 changed files with 162 additions and 90 deletions
88
Cargo.lock
generated
88
Cargo.lock
generated
|
@ -276,7 +276,7 @@ checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -293,7 +293,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -355,7 +355,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"serde",
|
"serde",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"zbus",
|
"zbus",
|
||||||
"zbus_names",
|
"zbus_names",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
|
@ -450,7 +450,7 @@ checksum = "1aca418a974d83d40a0c1f0c5cba6ff4bc28d8df099109ca459a2118d40b6322"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -713,14 +713,11 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"csv",
|
"csv",
|
||||||
"directories",
|
|
||||||
"dotenvy",
|
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"grid",
|
"grid",
|
||||||
"if_chain",
|
"if_chain",
|
||||||
"regex",
|
|
||||||
"rfd",
|
"rfd",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -771,7 +768,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"scratch",
|
"scratch",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -788,7 +785,7 @@ checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -810,7 +807,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -823,15 +820,6 @@ dependencies = [
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "directories"
|
|
||||||
version = "4.0.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
|
@ -1000,7 +988,7 @@ checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1359,12 +1347,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grid"
|
name = "grid"
|
||||||
version = "0.9.0"
|
version = "0.9.1-alpha.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0634107a3a005070dd73e27e74ecb691a94e9e5ba7829f434db7fbf73a6b5c47"
|
|
||||||
dependencies = [
|
|
||||||
"no-std-compat",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gtk-sys"
|
name = "gtk-sys"
|
||||||
|
@ -1777,12 +1760,6 @@ dependencies = [
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "no-std-compat"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nohash-hasher"
|
name = "nohash-hasher"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -1886,7 +1863,7 @@ dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1973,7 +1950,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2434,9 +2411,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.156"
|
version = "1.0.160"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4"
|
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
@ -2455,13 +2432,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.156"
|
version = "1.0.160"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
|
checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2472,7 +2449,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2667,7 +2644,7 @@ dependencies = [
|
||||||
"sha2",
|
"sha2",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"sqlx-rt",
|
"sqlx-rt",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2728,6 +2705,17 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "system-deps"
|
name = "system-deps"
|
||||||
version = "6.0.3"
|
version = "6.0.3"
|
||||||
|
@ -2780,7 +2768,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2862,7 +2850,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2932,7 +2920,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3090,7 +3078,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3124,7 +3112,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -3320,7 +3308,7 @@ checksum = "9539b6bd3eadbd9de66c9666b22d802b833da7e996bc06896142e09854a61767"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3546,7 +3534,7 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"zvariant_utils",
|
"zvariant_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3590,7 +3578,7 @@ dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
"zvariant_utils",
|
"zvariant_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3602,5 +3590,5 @@ checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -11,14 +11,17 @@ description = "An assistant tool to easily map a CSV spreadsheets collumns to a
|
||||||
[dependencies]
|
[dependencies]
|
||||||
sqlx = { version = "0.6.2", features = [ "runtime-tokio-native-tls" , "mysql" ] }
|
sqlx = { version = "0.6.2", features = [ "runtime-tokio-native-tls" , "mysql" ] }
|
||||||
tokio = { version = "1.25.0", features = ["full"] }
|
tokio = { version = "1.25.0", features = ["full"] }
|
||||||
dotenvy = "0.15.6"
|
# ["rt", "io-std", "macros", "parking_lot", "sync" ]
|
||||||
directories = "4.0.1"
|
# dotenvy = "0.15.6"
|
||||||
|
# directories = "4.0.1"
|
||||||
csv = "1.1.6"
|
csv = "1.1.6"
|
||||||
egui = "0.21.0"
|
egui = "0.21.0"
|
||||||
eframe = "0.21.0"
|
eframe = "0.21.0"
|
||||||
egui_extras = "0.21.0"
|
egui_extras = "0.21.0"
|
||||||
rfd = "0.11.1"
|
rfd = "0.11.1"
|
||||||
grid = "0.9.0"
|
# need remove_row() and remove_col(), Change back once pull request accepted
|
||||||
regex = "1.7.1"
|
grid = { path = "../grid/grid" }
|
||||||
|
# regex = "1.7.1"
|
||||||
chrono = "0.4.24"
|
chrono = "0.4.24"
|
||||||
if_chain = "1.0.2"
|
if_chain = "1.0.2"
|
||||||
|
# serde = "1.0.160"
|
||||||
|
|
3
mysql-connect.sh
Executable file
3
mysql-connect.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
sudo systemctl start docker
|
||||||
|
sleep 1
|
||||||
|
sudo docker exec -e IN_DOCKER -it csql-Opencart_dummy_DB-1 /bin/bash -c "mysql -pmauFJcuf5dhRMQrjj"
|
|
@ -60,8 +60,18 @@ impl BackendManger {
|
||||||
let mut csv_data = self.csv_data.lock().await;
|
let mut csv_data = self.csv_data.lock().await;
|
||||||
try_match_headers_to_fields(&mut db_table_data, None, &mut csv_data)
|
try_match_headers_to_fields(&mut db_table_data, None, &mut csv_data)
|
||||||
}
|
}
|
||||||
Communication::ImportDBEntries(usize) => {
|
|
||||||
todo!()
|
Communication::ImportDBEntries => {
|
||||||
|
let mut db_table_data = self.db_table_data.lock().await;
|
||||||
|
let mut csv_data = self.csv_data.lock().await;
|
||||||
|
|
||||||
|
if let Some(current_working_table_i) = db_table_data.current_working_table {
|
||||||
|
if let Some(current_working_table) =
|
||||||
|
db_table_data.tables.get_mut(current_working_table_i)
|
||||||
|
{
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Communication::SaveCSV(path) => {
|
Communication::SaveCSV(path) => {
|
||||||
todo!()
|
todo!()
|
||||||
|
@ -82,11 +92,13 @@ impl BackendManger {
|
||||||
&mut csv_data,
|
&mut csv_data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Communication::RemoveRow(usize) => {
|
Communication::RemoveRow(i) => {
|
||||||
todo!()
|
let mut csv_data = self.csv_data.lock().await;
|
||||||
|
csv_data.data.remove_row(i);
|
||||||
}
|
}
|
||||||
Communication::RemoveCol(usize) => {
|
Communication::RemoveCol(i) => {
|
||||||
todo!()
|
let mut csv_data = self.csv_data.lock().await;
|
||||||
|
csv_data.data.remove_col(i);
|
||||||
}
|
}
|
||||||
Communication::TryParseCol(col_index) => {
|
Communication::TryParseCol(col_index) => {
|
||||||
let mut csv_data = self.csv_data.lock().await;
|
let mut csv_data = self.csv_data.lock().await;
|
||||||
|
@ -103,9 +115,48 @@ impl BackendManger {
|
||||||
csv_data.is_parsed = true;
|
csv_data.is_parsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Communication::StartInserting(table_index, sender, oneshot_sender) => {
|
Communication::StartInserting(sender, oneshot_sender) => {
|
||||||
let csv_data = self.csv_data.lock().await;
|
let csv_data = self.csv_data.lock().await;
|
||||||
let db_table_data = self.db_table_data.lock().await;
|
let db_table_data = self.db_table_data.lock().await;
|
||||||
|
let table_index = db_table_data.current_working_table.unwrap();
|
||||||
|
let table = db_table_data.tables.get(table_index).unwrap();
|
||||||
|
|
||||||
|
let trans_start =
|
||||||
|
Table::start_transaction(self.db_connection.as_mut().unwrap()).await;
|
||||||
|
sender
|
||||||
|
.send(trans_start)
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|_| println!("db- failed to send Transaction Start"));
|
||||||
|
|
||||||
|
let start_i: usize = csv_data.are_headers.into();
|
||||||
|
|
||||||
|
let res = table
|
||||||
|
.truncate_table(self.db_connection.as_mut().unwrap())
|
||||||
|
.await;
|
||||||
|
sender.send(res).await.unwrap_or_else(|_| {
|
||||||
|
println!("db - failed to send start of insert into table")
|
||||||
|
});
|
||||||
|
for i in start_i..csv_data.data.rows() {
|
||||||
|
let row: Vec<&DataEntry> = csv_data.data[i].iter().collect();
|
||||||
|
let res = table
|
||||||
|
.insert_into_table(self.db_connection.as_mut().unwrap(), row)
|
||||||
|
.await;
|
||||||
|
println!(
|
||||||
|
" | Query: {}\n > Result: {:?}",
|
||||||
|
res.query, res.result
|
||||||
|
);
|
||||||
|
sender.send(res).await.unwrap_or_else(|_| {
|
||||||
|
println!("db - failed to send end of insert into table")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
oneshot_sender.send(true).unwrap_or_else(|_| {
|
||||||
|
println!("db - failed to send end of insert into table")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Communication::StartAppending(sender, oneshot_sender) => {
|
||||||
|
let csv_data = self.csv_data.lock().await;
|
||||||
|
let db_table_data = self.db_table_data.lock().await;
|
||||||
|
let table_index = db_table_data.current_working_table.unwrap();
|
||||||
let table = db_table_data.tables.get(table_index).unwrap();
|
let table = db_table_data.tables.get(table_index).unwrap();
|
||||||
let trans_start =
|
let trans_start =
|
||||||
Table::start_transaction(self.db_connection.as_mut().unwrap()).await;
|
Table::start_transaction(self.db_connection.as_mut().unwrap()).await;
|
||||||
|
@ -113,7 +164,7 @@ impl BackendManger {
|
||||||
sender
|
sender
|
||||||
.send(trans_start)
|
.send(trans_start)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| println!("failed to send Transaction Start"));
|
.unwrap_or_else(|_| println!("db- failed to send Transaction Start"));
|
||||||
|
|
||||||
let start_i: usize = csv_data.are_headers.into();
|
let start_i: usize = csv_data.are_headers.into();
|
||||||
|
|
||||||
|
@ -129,11 +180,11 @@ impl BackendManger {
|
||||||
sender
|
sender
|
||||||
.send(res)
|
.send(res)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| println!("failed to send insert into table"));
|
.unwrap_or_else(|_| println!("db - failed to send append to table"));
|
||||||
}
|
}
|
||||||
oneshot_sender
|
oneshot_sender
|
||||||
.send(true)
|
.send(true)
|
||||||
.unwrap_or_else(|_| println!("Failed to send end of insertin transaction"));
|
.unwrap_or_else(|_| println!("Failed to send end of append transaction"));
|
||||||
}
|
}
|
||||||
Communication::TryCommit(sender) => {
|
Communication::TryCommit(sender) => {
|
||||||
sender
|
sender
|
||||||
|
@ -243,12 +294,13 @@ pub enum Communication {
|
||||||
),
|
),
|
||||||
LoadImportFilePath(String),
|
LoadImportFilePath(String),
|
||||||
GetTableDescription(usize),
|
GetTableDescription(usize),
|
||||||
ImportDBEntries(usize),
|
ImportDBEntries,
|
||||||
RemoveCol(usize),
|
RemoveCol(usize),
|
||||||
RemoveRow(usize),
|
RemoveRow(usize),
|
||||||
SaveCSV(String),
|
SaveCSV(String),
|
||||||
TryParseCol(usize),
|
TryParseCol(usize),
|
||||||
StartInserting(usize, Sender<QueryResult>, oneshot::Sender<bool>),
|
StartAppending(Sender<QueryResult>, oneshot::Sender<bool>),
|
||||||
|
StartInserting(Sender<QueryResult>, oneshot::Sender<bool>),
|
||||||
TryCommit(oneshot::Sender<QueryResult>),
|
TryCommit(oneshot::Sender<QueryResult>),
|
||||||
TryRollBack(oneshot::Sender<QueryResult>),
|
TryRollBack(oneshot::Sender<QueryResult>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{error::Error, sync::Arc};
|
|
||||||
|
|
||||||
use super::database_handler::FieldDescription;
|
use super::database_handler::FieldDescription;
|
||||||
|
|
||||||
|
use std::{error::Error, sync::Arc};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ImportedData {
|
pub struct ImportedData {
|
||||||
pub data: grid::Grid<DataEntry>,
|
pub data: grid::Grid<DataEntry>,
|
||||||
|
@ -16,6 +16,7 @@ pub struct DataEntry {
|
||||||
pub curr_field_description: Option<FieldDescription>,
|
pub curr_field_description: Option<FieldDescription>,
|
||||||
pub is_parsed: Option<Result<(), Arc<dyn Error + Send + Sync>>>,
|
pub is_parsed: Option<Result<(), Arc<dyn Error + Send + Sync>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImportedData {
|
impl ImportedData {
|
||||||
pub fn load_csv(&mut self) -> Result<(), Box<dyn Error + Send>> {
|
pub fn load_csv(&mut self) -> Result<(), Box<dyn Error + Send>> {
|
||||||
match csv::Reader::from_path(self.path.as_str()) {
|
match csv::Reader::from_path(self.path.as_str()) {
|
||||||
|
|
|
@ -116,6 +116,42 @@ impl Table {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub async fn truncate_table(&self, connection: &mut MySqlConnection) -> QueryResult {
|
||||||
|
match connection
|
||||||
|
.execute(format!("truncate {}", self.name).as_str())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(res) => {
|
||||||
|
return QueryResult {
|
||||||
|
query: format!("truncate {}", self.name),
|
||||||
|
result: Ok(res),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
return QueryResult {
|
||||||
|
query: format!("truncate {}", self.name),
|
||||||
|
result: Err(Box::new(e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub async fn query_for_table_entries(
|
||||||
|
&mut self,
|
||||||
|
connection: &mut MySqlConnection,
|
||||||
|
) -> QueryResult {
|
||||||
|
let res = sqlx::query(format!("select * from {}", self.name).as_str())
|
||||||
|
.fetch_all(connection)
|
||||||
|
.await;
|
||||||
|
match res {
|
||||||
|
Ok(rows) => {
|
||||||
|
for row in rows {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => todo!(),
|
||||||
|
}
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
pub async fn insert_into_table(
|
pub async fn insert_into_table(
|
||||||
&self,
|
&self,
|
||||||
connection: &mut MySqlConnection,
|
connection: &mut MySqlConnection,
|
||||||
|
|
|
@ -15,13 +15,9 @@ pub struct DBTransactionWindow {
|
||||||
is_log_finished: bool,
|
is_log_finished: bool,
|
||||||
is_finished: bool,
|
is_finished: bool,
|
||||||
final_result_receiver: Option<oneshot::Receiver<QueryResult>>,
|
final_result_receiver: Option<oneshot::Receiver<QueryResult>>,
|
||||||
working_table_index: usize,
|
|
||||||
}
|
}
|
||||||
impl DBTransactionWindow {
|
impl DBTransactionWindow {
|
||||||
pub fn default(
|
pub fn default(sender: Sender<Communication>) -> DBTransactionWindow {
|
||||||
sender: Sender<Communication>,
|
|
||||||
working_table_index: usize,
|
|
||||||
) -> DBTransactionWindow {
|
|
||||||
DBTransactionWindow {
|
DBTransactionWindow {
|
||||||
sender,
|
sender,
|
||||||
log_history: vec![],
|
log_history: vec![],
|
||||||
|
@ -30,7 +26,6 @@ impl DBTransactionWindow {
|
||||||
final_result_receiver: None,
|
final_result_receiver: None,
|
||||||
is_log_finished_receiver: None,
|
is_log_finished_receiver: None,
|
||||||
is_log_finished: false,
|
is_log_finished: false,
|
||||||
working_table_index,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,11 +87,7 @@ impl DBTransactionWindow {
|
||||||
self.is_log_finished_receiver = Some(finished_receiver);
|
self.is_log_finished_receiver = Some(finished_receiver);
|
||||||
self.logs_receiver = Some(log_receiver);
|
self.logs_receiver = Some(log_receiver);
|
||||||
self.sender
|
self.sender
|
||||||
.try_send(Communication::StartInserting(
|
.try_send(Communication::StartAppending(log_sender, finished_sender))
|
||||||
self.working_table_index,
|
|
||||||
log_sender,
|
|
||||||
finished_sender,
|
|
||||||
))
|
|
||||||
.unwrap_or_else(|_| println!("Failed to send startInserting"));
|
.unwrap_or_else(|_| println!("Failed to send startInserting"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,3 +180,9 @@ pub struct OptionsDBTransactionWindow {
|
||||||
substitute_zero_dates_for_null: bool,
|
substitute_zero_dates_for_null: bool,
|
||||||
remove_id_field_from_insert: bool,
|
remove_id_field_from_insert: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum TransactionType {
|
||||||
|
Append,
|
||||||
|
Save,
|
||||||
|
Import,
|
||||||
|
}
|
||||||
|
|
|
@ -100,17 +100,9 @@ impl App for CSQL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("No transaction window, creating...");
|
println!("Found a current_working _table");
|
||||||
if let Ok(db_table_data) = self.db_table_data_handle.try_lock() {
|
self.db_transaction_window =
|
||||||
println!("got a db_lock");
|
Some(DBTransactionWindow::default(self.sender.clone()))
|
||||||
if let Some(cw_table_i) = db_table_data.current_working_table {
|
|
||||||
println!("Found a current_working _table");
|
|
||||||
self.db_transaction_window = Some(DBTransactionWindow::default(
|
|
||||||
self.sender.clone(),
|
|
||||||
cw_table_i,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue