MCPcopy Create free account
hub / github.com/douglance/devsql / execute

Method execute

crates/vcsql/src/sql/engine.rs:140–154  ·  view source on GitHub ↗

Executes a SQL query and returns the results. The query can use any SQL features supported by SQLite, including JOINs, CTEs, window functions, and aggregations.

(&self, query: &str)

Source from the content-addressed store, hash-verified

138 /// The query can use any SQL features supported by SQLite, including JOINs,
139 /// CTEs, window functions, and aggregations.
140 pub fn execute(&self, query: &str) -> Result<QueryResult> {
141 let mut stmt = self.conn.prepare(query)?;
142
143 let column_names: Vec<String> = stmt.column_names().iter().map(|s| s.to_string()).collect();
144
145 let rows: Vec<Vec<Value>> = stmt
146 .query_map([], |row| Ok(row_to_values(row, column_names.len())))?
147 .filter_map(|r| r.ok())
148 .collect();
149
150 Ok(QueryResult {
151 columns: column_names,
152 rows,
153 })
154 }
155}
156
157fn row_to_values(row: &Row, col_count: usize) -> Vec<Value> {

Callers 15

execute_queryFunction · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45
populateMethod · 0.45

Calls 1

row_to_valuesFunction · 0.85

Tested by 3

test_query_commitsFunction · 0.36
test_query_branchesFunction · 0.36