MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / query_db

Function query_db

crates/create-rust-app/src/dev/controller.rs:37–44  ·  view source on GitHub ↗

/db/query # Errors query fails # Panics cannot connect to the database

(db: &Database, body: &MySqlQuery)

Source from the content-addressed store, hash-verified

35/// # Panics
36/// * cannot connect to the database
37pub fn query_db(db: &Database, body: &MySqlQuery) -> Result<String, diesel::result::Error> {
38 let q = format!("SELECT json_agg(q) as json FROM ({}) q;", body.query);
39 let mut db = db.get_connection().unwrap();
40
41 Ok(sql_query(q.as_str())
42 .get_result::<MyQueryResult>(&mut db)?
43 .json)
44}
45
46/// /db/is-connected
47#[must_use]

Callers

nothing calls this directly

Calls 1

get_connectionMethod · 0.80

Tested by

no test coverage detected