From: Andrea Zagli Date: Sat, 1 Jun 2024 08:26:33 +0000 (+0200) Subject: Example: added columns inspection. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=0847a5964d5c42e215b1cc1af902951db6329aeb;p=rust%2Fzakgrid Example: added columns inspection. --- diff --git a/examples/grid.rs b/examples/grid.rs index 2d11cbf..a8df8e2 100644 --- a/examples/grid.rs +++ b/examples/grid.rs @@ -15,7 +15,7 @@ use actix_web::{ }; use futures::TryStreamExt; -use sqlx::{Connection, SqliteConnection, Row, Column}; +use sqlx::{database::HasStatement, sqlite::SqliteStatement, Column, Connection, Execute, Executor, Row, SqliteConnection, Statement}; use std::str::FromStr; #[derive(Debug, Deserialize)] @@ -94,13 +94,20 @@ async fn index( s.push_str(format!("col {} title {}
\n", i, v.title()).as_str()); } + let mut conn = SqliteConnection::connect("examples/grid.db").await.unwrap(); + + let p = conn.prepare("SELECT * FROM clients WHERE FALSE").await.unwrap(); + + //let q: sqlx::query::Query<'_, sqlx::Sqlite, _> = sqlx::query("SELECT * FROM clients WHERE FALSE"); + //let p = q.statement().unwrap(); + + s.push_str(&format!("
Sql columns: {:?}
", p.columns())); + s.push_str("

\n"); s.push_str("\n"); let header = grid.header(); s.push_str(header.as_str()); - let mut conn = SqliteConnection::connect("examples/grid.db").await.unwrap(); - let mut rows = sqlx::query("SELECT * FROM clients").fetch(&mut conn); while let Some(row) = rows.try_next().await.unwrap() { let cols = row.columns();