cargo fmt

pull/1/head
Takayuki Maeda 3 years ago
parent 78c7975706
commit d88a79f0a0

@ -1,9 +1,8 @@
use crate::app::{App};
use crate::app::App;
use crate::event::Key;
use crate::utils::get_databases;
use sqlx::mysql::MySqlPool;
pub async fn handler<'a>(_key: Key, app: &mut App<'a>, pool: &MySqlPool) -> anyhow::Result<()> {
for db in get_databases(pool).await? {
app.databases.push(db)

@ -5,10 +5,7 @@ use tui::{
layout::{Constraint, Direction, Layout},
style::{Color, Style},
text::{Span, Spans},
widgets::{
Block, Borders, Cell, Clear, List,
ListItem, Paragraph, Row, Table,
},
widgets::{Block, Borders, Cell, Clear, List, ListItem, Paragraph, Row, Table},
Frame,
};
use unicode_width::UnicodeWidthStr;
@ -91,13 +88,13 @@ pub fn draw<B: Backend>(f: &mut Frame<'_, B>, app: &mut App) -> anyhow::Result<(
let databases = app.databases.clone();
let tables: Vec<ListItem> = databases[app.selected_database.selected().unwrap_or(0)]
.tables
.iter()
.map(|i| {
ListItem::new(vec![Spans::from(Span::raw(&i.name))])
.style(Style::default().fg(Color::White))
})
.collect();
.tables
.iter()
.map(|i| {
ListItem::new(vec![Spans::from(Span::raw(&i.name))])
.style(Style::default().fg(Color::White))
})
.collect();
let tasks = List::new(tables)
.block(Block::default().borders(Borders::ALL).title("Tables"))
.highlight_style(Style::default().fg(Color::Green))

@ -1,5 +1,5 @@
use crate::app::{Database, Table};
use chrono::{NaiveDate};
use chrono::NaiveDate;
use futures::TryStreamExt;
use sqlx::mysql::MySqlPool;
use sqlx::{Column, Executor, Row, TypeInfo};
@ -33,8 +33,7 @@ pub async fn get_records(
table: &Table,
pool: &MySqlPool,
) -> anyhow::Result<(Vec<String>, Vec<Vec<String>>)> {
pool
.execute(format!("use `{}`", database.name).as_str())
pool.execute(format!("use `{}`", database.name).as_str())
.await?;
let table_name = format!("SELECT * FROM `{}`", table.name);
let mut rows = sqlx::query(table_name.as_str()).fetch(pool);

Loading…
Cancel
Save