(builder: RequestBuilder, sql: &str, with_stats: bool)
| 144 | } |
| 145 | |
| 146 | pub(crate) async fn run_sql(builder: RequestBuilder, sql: &str, with_stats: bool) -> Result<(), anyhow::Error> { |
| 147 | let now = Instant::now(); |
| 148 | |
| 149 | let json = builder |
| 150 | .body(sql.to_owned()) |
| 151 | .send() |
| 152 | .await? |
| 153 | .ensure_content_type("application/json") |
| 154 | .await? |
| 155 | .text() |
| 156 | .await?; |
| 157 | |
| 158 | let stmt_result_json: Vec<SqlStmtResult> = serde_json::from_str(&json).context("malformed sql response")?; |
| 159 | |
| 160 | let mut out = String::new(); |
| 161 | print_stmt_result(&stmt_result_json, with_stats.then_some(now.elapsed()), &mut out)?; |
| 162 | println!("{out}"); |
| 163 | |
| 164 | Ok(()) |
| 165 | } |
| 166 | |
| 167 | fn stmt_result_to_table(client: PsqlClient, stmt_result: &SqlStmtResult) -> anyhow::Result<(StmtStats, tabled::Table)> { |
| 168 | let stats = StmtStats::from(stmt_result); |
no test coverage detected
searching dependent graphs…