# sqlite/scalar-async Async twin of `sqlite/scalar` — read the first column of the first row off-thread. Returns a Future of a value or `nil`. ## Syntax
[sqlite/scalar-async $db $sql ?params...]
## Parameters - `$db` — database handle - `$sql` — SQL query - `?params...` — optional bind values, as separate args or a single `@{}` vector ## Examples
def db [sqlite/open ":memory:"]
[sqlite/exec $db "CREATE TABLE t (id INTEGER)"]
[sqlite/exec $db "INSERT INTO t VALUES (1), (2)"]
[await [sqlite/scalar-async $db "SELECT count(*) FROM t"]]   # → 2
## Returns Future; `[await ...]` yields the first column of the first row (number or string), or `nil` when no row matches, the query has no columns, or the cell is NULL. Worker errors resolve as `%Err{:message}`; submit-time errors (bad handle, non-string SQL) return `%Err` directly. The first async call switches the handle to async-only, so later sync `sqlite/*` calls on it return `%Err`. `sqlite/close` drains queued jobs before closing. ## See Also `sqlite/scalar`, `sqlite/query-one-async`, `sqlite/query-async`