MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / run_sql

Function run_sql

crates/cli/src/subcommands/sql.rs:146–165  ·  view source on GitHub ↗
(builder: RequestBuilder, sql: &str, with_stats: bool)

Source from the content-addressed store, hash-verified

144}
145
146pub(crate) async fn run_sql(builder: RequestBuilder, sql: &str, with_stats: bool) -> Result<(), anyhow::Error> {
147 let now = Instant::now();
148
149 let json = builder
150 .body(sql.to_owned())
151 .send()
152 .await?
153 .ensure_content_type("application/json")
154 .await?
155 .text()
156 .await?;
157
158 let stmt_result_json: Vec<SqlStmtResult> = serde_json::from_str(&json).context("malformed sql response")?;
159
160 let mut out = String::new();
161 print_stmt_result(&stmt_result_json, with_stats.then_some(now.elapsed()), &mut out)?;
162 println!("{out}");
163
164 Ok(())
165}
166
167fn stmt_result_to_table(client: PsqlClient, stmt_result: &SqlStmtResult) -> anyhow::Result<(StmtStats, tabled::Table)> {
168 let stats = StmtStats::from(stmt_result);

Callers 2

execFunction · 0.85
execFunction · 0.85

Calls 9

from_strFunction · 0.85
print_stmt_resultFunction · 0.85
ensure_content_typeMethod · 0.80
elapsedMethod · 0.80
sendMethod · 0.65
newFunction · 0.50
OkFunction · 0.50
textMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…