import { PreparedQuery } from "https://deno.land/x/sqlite@v3.4.1/src/query.ts";
A prepared query which can be executed many times.
Constructors
Type Parameters
Properties
Methods
Binds the given parameters to the query and returns an array containing all resulting rows.
Calling all
invalidates any iterators
previously returned by calls to iter
.
Using an invalidated iterator is a bug.
To avoid SQL injection, user-provided values should always be passed to the database through a query parameter.
See QueryParameterSet
for documentation on
how values can be bound to SQL statements.
See QueryParameter
for documentation on how
values are returned from the database.
Like all
except each row is returned
as an object containing key-value pairs.
Returns the column names for the query results.
This method returns an array of objects, where each object has the following properties:
Property | Value |
---|---|
name |
the result of sqlite3_column_name |
originName |
the result of sqlite3_column_origin_name |
tableName |
the result of sqlite3_column_table_name |
Binds the given parameters to the query and executes the query, ignoring any rows which might be returned.
Using this method is more efficient when the rows returned by a query are not needed or the query does not return any rows.
Calling execute
invalidates any iterators
previously returned by calls to iter
.
Using an invalidated iterator is a bug.
To avoid SQL injection, user-provided values should always be passed to the database through a query parameter.
See QueryParameterSet
for documentation on
how values can be bound to SQL statements.
Closes the prepared query. This must be called once the query is no longer needed to avoid leaking resources.
After a prepared query has been finalized,
trying to call iter
, all
, one
,
execute
, or columns
, or using iterators which where
previously obtained from the finalized query
is a bug.
finalize
may safely be called multiple
times.
Binds the given parameters to the query and returns an iterator over rows.
Using an iterator avoids loading all returned rows into memory and hence allows to process a large number of rows.
Example:
const query = db.prepareQuery<[number, string]>("SELECT id, name FROM people");
for (const [id, name] of query.iter()) {
// ...
}
Calling iter
invalidates any iterators previously returned
from this prepared query. Using an invalidated iterator is a bug.
To avoid SQL injection, user-provided values should always be passed to the database through a query parameter.
See QueryParameterSet
for documentation on
how values can be bound to SQL statements.
See QueryParameter
for documentation on how
values are returned from the database.
Like iter
except each row is returned
as an object containing key-value pairs.
Binds the given parameters to the query and returns exactly one row.
If the query does not return exactly one row, this throws an error.
Calling one
invalidates any iterators
previously returned by calls to iter
.
Using an invalidated iterator is a bug.
To avoid SQL injection, user-provided values should always be passed to the database through a query parameter.
See QueryParameterSet
for documentation on
how values can be bound to SQL statements.
See QueryParameter
for documentation on how
values are returned from the database.