Skip to main content
Module

x/sqlite3/mod.ts>Database#exec

Fastest & correct JavaScript bindings to SQLite3 C API, using Deno FFI.
Go to Latest
method Database.prototype.exec
Re-export
import { Database } from "https://deno.land/x/sqlite3@0.6.1/mod.ts";

Simply executes the SQL statement (supports multiple statements separated by semicolon). Returns the number of changes made by last statement.

Example:

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

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

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

// Pragma statements
db.exec("pragma journal_mode = WAL");
db.exec("pragma synchronous = normal");
db.exec("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

sql: string

Returns

number