Skip to content

eval

Package eval adds an eval() scalar function that runs dynamic SQL on the calling connection and returns the result as text — sqlean’s distinctive “SQL from SQL” capability, which no other pure-Go SQLite driver exposes.

eval(sql) -- run sql, return its result values concatenated
eval(sql, sep) -- ...joined by sep (default '')

Example:

SELECT eval('SELECT 6 * 7'); -- '42'
SELECT eval('SELECT name FROM t', ', '); -- 'alice, bob, carol'
SELECT eval('CREATE TABLE log(msg)'); -- '' (no output, side effect applied)

The SQL runs on the same connection (a re-entrant prepared statement, the proven pattern ext/statement uses), so it sees the same tables, pragmas, and transaction. One statement per call.

eval() executes arbitrary SQL. Never pass untrusted input to it — treat it exactly like building a query by string concatenation. It is not registered by default for that reason; opt in explicitly per connection or via the auto sub-package.


Full API: pkg.go.dev/gosqlite.org/ext/eval