fix user config

pull/2/head
Takayuki Maeda 3 years ago
parent 14023f06a0
commit b3fcef2caa

69
Cargo.lock generated

@ -122,12 +122,6 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "bytes"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "cargo-platform"
version = "0.1.1"
@ -306,6 +300,12 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "form_urlencoded"
version = "1.0.1"
@ -475,7 +475,7 @@ dependencies = [
"serde",
"serde_json",
"sqlx",
"tokio 1.7.1",
"tokio",
"toml",
"tui",
"unicode-width",
@ -679,6 +679,18 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "mio-named-pipes"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
dependencies = [
"log",
"mio 0.6.23",
"miow 0.3.7",
"winapi 0.3.9",
]
[[package]]
name = "mio-uds"
version = "0.6.8"
@ -1246,7 +1258,7 @@ dependencies = [
"base64 0.13.0",
"bitflags",
"byteorder",
"bytes 0.5.6",
"bytes",
"chrono",
"crc",
"crossbeam-channel",
@ -1312,7 +1324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63fc5454c9dd7aaea3a0eeeb65ca40d06d0d8e7413a8184f7c3a3ffa5056190b"
dependencies = [
"once_cell",
"tokio 0.2.25",
"tokio",
"tokio-rustls",
]
@ -1418,37 +1430,21 @@ version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092"
dependencies = [
"bytes 0.5.6",
"bytes",
"fnv",
"futures-core",
"iovec",
"lazy_static",
"libc",
"memchr",
"mio 0.6.23",
"mio-named-pipes",
"mio-uds",
"num_cpus",
"pin-project-lite 0.1.12",
"slab",
"tokio-macros 0.2.6",
]
[[package]]
name = "tokio"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fb2ed024293bb19f7a5dc54fe83bf86532a44c12a2bb8ba40d64a4509395ca2"
dependencies = [
"autocfg 1.0.1",
"bytes 1.0.1",
"libc",
"memchr",
"mio 0.7.11",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite 0.2.6",
"signal-hook-registry",
"tokio-macros 1.2.0",
"slab",
"tokio-macros",
"winapi 0.3.9",
]
@ -1463,17 +1459,6 @@ dependencies = [
"syn",
]
[[package]]
name = "tokio-macros"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tokio-rustls"
version = "0.14.1"
@ -1482,7 +1467,7 @@ checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a"
dependencies = [
"futures-core",
"rustls",
"tokio 0.2.25",
"tokio",
"webpki",
]

@ -1,57 +0,0 @@
use crate::app::App;
use crate::event::Key;
use futures::TryStreamExt;
use sqlx::mysql::MySqlPool;
use sqlx::{Column, Executor, Row, TypeInfo};
pub async fn handler<'a>(key: Key, app: &mut App<'a>, pool: &MySqlPool) -> anyhow::Result<()> {
match app.selected_database.selected() {
Some(index) => {
&app.databases[index].next();
let db = &app.databases[app.selected_database.selected().unwrap_or(0)];
&pool.execute(format!("use {}", db.name).as_str()).await?;
let table_name = format!(
"SELECT * FROM {}",
&db.tables[db.selected_table.selected().unwrap_or(0)].name
);
let mut rows = sqlx::query(table_name.as_str()).fetch(pool);
let headers = sqlx::query(
format!(
"desc {}",
&db.tables[db.selected_table.selected().unwrap_or(0)].name
)
.as_str(),
)
.fetch_all(pool)
.await?
.iter()
.map(|table| table.get(0))
.collect::<Vec<String>>();
let mut records = vec![];
while let Some(row) = rows.try_next().await? {
let mut row_vec = vec![];
for col in row.columns() {
let col_name = col.name();
match col.type_info().clone().name() {
"INT" => {
let value: i32 = row.try_get(col_name).unwrap_or(0);
row_vec.push(value.to_string());
}
"VARCHAR" => {
let value: String = row.try_get(col_name).unwrap_or("".to_string());
row_vec.push(value);
}
_ => (),
}
}
records.push(row_vec)
}
app.record_table.rows = records;
app.record_table.headers = headers;
}
None => (),
}
Ok(())
}
Loading…
Cancel
Save