Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/sqlite3/mod.ts>Database#exec

The fastest and correct SQLite3 module for Deno runtime
Latest
method Database.prototype.exec
import { Database } from "https://deno.land/x/sqlite3@0.12.0/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