MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / query_rows

Method query_rows

nodedb-test-support/src/pgwire_harness/query.rs:90–109  ·  view source on GitHub ↗

Execute a SQL statement, returning every row as a Vec of its column values (in projection order). Column count is taken from the first row received.

(&self, sql: &str)

Source from the content-addressed store, hash-verified

88 /// values (in projection order). Column count is taken from the first
89 /// row received.
90 pub async fn query_rows(&self, sql: &str) -> Result<Vec<Vec<String>>, String> {
91 let client = self.client.as_ref();
92 match client.simple_query(sql).await {
93 Ok(msgs) => {
94 let mut rows: Vec<Vec<String>> = Vec::new();
95 for msg in msgs {
96 if let tokio_postgres::SimpleQueryMessage::Row(row) = msg {
97 let n = row.len();
98 let mut cols: Vec<String> = Vec::with_capacity(n);
99 for i in 0..n {
100 cols.push(row.get(i).unwrap_or("").to_string());
101 }
102 rows.push(cols);
103 }
104 }
105 Ok(rows)
106 }
107 Err(e) => Err(pg_error_detail(&e)),
108 }
109 }
110
111 /// Execute a SQL statement expecting success (no result needed).
112 pub async fn exec(&self, sql: &str) -> Result<(), String> {

Calls 6

to_stringMethod · 0.80
pg_error_detailFunction · 0.70
as_refMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
getMethod · 0.45