Skip to main content
sqlite - Node documentation

Usage in Deno

import * as mod from "node:sqlite";
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> This module is not implemented.</p> </div></div>

The node:sqlite module facilitates working with SQLite databases. To access it:

import sqlite from 'node:sqlite';

This module is only available under the node: scheme. The following will not work:

import sqlite from 'node:sqlite';

The following example shows the basic usage of the node:sqlite module to open an in-memory database, write data to the database, and then read the data back.

import { DatabaseSync } from 'node:sqlite';
const database = new DatabaseSync(':memory:');

// Execute SQL statements from strings.
database.exec(`
  CREATE TABLE data(
    key INTEGER PRIMARY KEY,
    value TEXT
  ) STRICT
`);
// Create a prepared statement to insert data into the database.
const insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
// Execute the prepared statement with bound values.
insert.run(1, 'hello');
insert.run(2, 'world');
// Create a prepared statement to read data from the database.
const query = database.prepare('SELECT * FROM data ORDER BY key');
// Execute the prepared statement and log the result set.
console.log(query.all());
// Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]

Classes

c
DatabaseSync

This class represents a single connection to a SQLite database. All APIsexposed by this class execute synchronously.

c
StatementSync

This class represents a single prepared statement. This class cannot beinstantiated via its constructor. Instead, instances are created via thedatabase.prepare() method. All APIs exposed by this class executesynchronously.

Interfaces

I
DatabaseSyncOptions
No documentation available

Type Aliases

T
SupportedValueType
No documentation available