Skip to main content
Module

x/sqlite3/mod.ts>Database#execute

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

Simply executes the SQL, without returning anything.

Example:

// Create table
db.execute("create table users (id integer not null, username varchar(20) not null)");

// Inserts
db.execute("insert into users (id, username) values(?, ?)", id, username);

// Or run SQL safely using Template Strings!
db.execute`insert into users (id, username) values(${id}, ${username})`;

// Insert with named parameters
db.execute("insert into users (id, username) values(:id, :username)", { id, username });

// Pragma statements
db.execute("pragma journal_mode = WAL");
db.execute("pragma synchronous = normal");
db.execute("pragma temp_store = memory");

Under the hood, it uses sqlite3_exec if no parameters are given to bind with the SQL statement, a prepared statement otherwise.

Parameters

strings: TemplateStringsArray
...args: BindValue[]

Parameters

sql: string
...args: BindValue[]

Parameters

sql: string
args: Record<string, BindValue>