Execute a SQL query and return structured results. Retries once with a fresh connection on I/O failure.
(&self, sql: &str)
| 35 | /// |
| 36 | /// Retries once with a fresh connection on I/O failure. |
| 37 | pub async fn query(&self, sql: &str) -> NodeDbResult<QueryResult> { |
| 38 | let mut conn = self.pool.acquire().await?; |
| 39 | match conn.execute_sql(sql).await { |
| 40 | Ok(r) => Ok(r), |
| 41 | Err(e) if is_connection_error(&e) => { |
| 42 | drop(conn); |
| 43 | let mut conn = self.pool.acquire().await?; |
| 44 | conn.execute_sql(sql).await |
| 45 | } |
| 46 | Err(e) => Err(e), |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Execute a DDL command. |
| 51 | pub async fn ddl(&self, sql: &str) -> NodeDbResult<QueryResult> { |
no test coverage detected