23 Value vsql = pop_value(vm);
29 SqlHandle *h = sql_reg_get(hid);
30 if (!h || !h->db || !sql) {
35 sqlite3_stmt *stmt = NULL;
36 if (sqlite3_prepare_v2(h->db, sql, -1, &stmt, NULL) != SQLITE_OK) {
43 int ncols = sqlite3_column_count(stmt);
44 while (sqlite3_step(stmt) == SQLITE_ROW) {
46 for (
int i = 0; i < ncols; i++) {
47 const char *
name = sqlite3_column_name(stmt, i);
48 int type = sqlite3_column_type(stmt, i);
52 kv =
make_int((int64_t)sqlite3_column_int64(stmt, i));
55 kv =
make_float(sqlite3_column_double(stmt, i));
58 kv =
make_string((
const char *)sqlite3_column_text(stmt, i));
74 sqlite3_finalize(stmt);
77 Value v1 = pop_value(vm);
int map_set(Value *vm, const char *key, Value v)
Insert or replace a key in the map.
Value make_map_empty(void)
Construct a new empty map Value.
push_value(vm, make_array_from_values(NULL, 0))
Tagged union representing a Fun value.
Value make_nil(void)
Construct a nil Value.
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Value make_float(double v)
Construct a Value representing a double-precision float.
int array_push(Value *v, Value newElem)
Append a Value to an array.
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Value make_array_from_values(const Value *vals, int count)
Create an array Value by copying items from an input span.