MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / sqlite_query

Function sqlite_query

aiscript-vm/src/stdlib/db/sqlite.rs:180–203  ·  view source on GitHub ↗
(state: &mut State<'gc>, args: Vec<Value<'gc>>)

Source from the content-addressed store, hash-verified

178}
179
180fn sqlite_query<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
181 if args.is_empty() {
182 return Err(VmError::RuntimeError(
183 "query() requires at least a SQL query string.".into(),
184 ));
185 }
186
187 let sql = args[0].as_string()?;
188 let ctx = state.get_context();
189 let conn = state.sqlite_connection.as_ref().unwrap();
190
191 let rows = execute_query(
192 conn,
193 sql.to_str().unwrap(),
194 args.into_iter().skip(1).collect(),
195 )?;
196
197 let mut results = Vec::new();
198 for row in rows {
199 results.push(row_to_object(ctx, &row));
200 }
201
202 Ok(Value::array(&ctx, results))
203}
204
205fn sqlite_query_as<'gc>(
206 state: &mut State<'gc>,

Callers

nothing calls this directly

Calls 8

RuntimeErrorClass · 0.85
as_stringMethod · 0.80
get_contextMethod · 0.80
to_strMethod · 0.80
pushMethod · 0.80
execute_queryFunction · 0.70
row_to_objectFunction · 0.70
as_refMethod · 0.45

Tested by

no test coverage detected