sql.QueryTyped
Example
Direct usage examples demonstrating typed queries with parameter binding for all SQLite data types.
This was recently added in version (2025.05.29). It might only be available on the Dev Branch right now.
Performs a query on the local SQLite database with proper type handling and parameter binding, returns a table as result set, empty table if no results, and false on error. Unlike sql.Query, this function properly handles SQLite data types and allows safe parameter binding to prevent SQL injection attacks.
This function only executes a single SQL statement, unlike sql.Query which can execute multiple statements separated by semicolons.
Large INTEGER values (beyond ±9,007,199,254,740,991) are returned as strings to preserve exact values. This is because Lua represents all numbers as doubles, which lose precision for integers larger than 2⁵³-1. Returning them as strings prevents data corruption from rounding errors.
?
parameter placeholders.
?
placeholders instead of string concatenation to prevent SQL injection vulnerabilities.false
is returned if there is an error (See sql.LastError), otherwise a table with properly typed column values (empty table if no results).Direct usage examples demonstrating typed queries with parameter binding for all SQLite data types.