From 0847a5964d5c42e215b1cc1af902951db6329aeb Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 1 Jun 2024 10:26:33 +0200 Subject: [PATCH] Example: added columns inspection. --- examples/grid.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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(); -- 2.49.0