Skip to main content
Module

x/sqlite3/mod.ts>PreparedStatement

Fast, native bindings to SQLite3 C API, using Deno FFI.
Go to Latest
class PreparedStatement
Re-export
import { PreparedStatement } from "https://deno.land/x/sqlite3@0.4.4/mod.ts";

Represents a prepared statement. Should only be created by Database.prepare().

Constructors

new
PreparedStatement(db: Database, handle: sqlite3_stmt)

Properties

readonly
bindParameterCount: number

Binding parameter count in the prepared statement.

readonly
columnCount: number

Column count in current row.

readonly
db: Database

Database associated with the Prepared Statement

readonly
expandedSql: string

SQL string including bindings

readonly
readonly: boolean

Whether this statement doesn't make any direct changes to the DB

readonly
row: Row

Current row

readonly
sql: string

The SQL string that we passed when creating statement

readonly
unsafeRawHandle: Deno.UnsafePointer

Unsafe Raw Handle (pointer) to the sqlite_stmt object.

Methods

bind(param: number | string, value: BindValue): void

Bind a parameter for the prepared query either by index or name.

bindAll(...values: BindValue[]): void

Binds all parameters to the prepared statement. This is a shortcut for calling bind() for each parameter.

bindAllNamed(values: Record<string, BindValue>): void
bindParameterIndex(name: string): number

Get index of a binding parameter by its name.

bindParameterName(index: number): string

Get name of a binding parameter by its index.

Clears any previously set binding parameters to NULL

column<T extends ColumnValue = ColumnValue>(index: number): T

Return value of a column at given index in current row.

columnName(index: number): string

Return the name of the column at given index in current row.

columnType(index: number): SqliteType

Return the data type of the column at given index in current row.

execute(...args: BindValue[]): void

Adds another step to prepared statement to be executed. Don't forget to call finalize.

execute(args: Record<string, BindValue>): void
finalize(): void

Finalize and run the prepared statement.

This also frees up any resources related to the statement. And clears all references to the buffers as they're no longer needed, allowing V8 to GC them.

reset(): void

Resets the prepared statement to its initial state.

step(): Row | undefined

Adds a step to the prepared statement, using current bindings.

[Symbol.iterator](): IterableIterator<Row>

Returns an iterator for rows.