
Security News
CISA Extends MITRE Contract as Crisis Accelerates Alternative CVE Coordination Efforts
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
libSQL is an open source, open contribution fork of SQLite. This source repository contains libSQL API bindings for Node, which aims to be compatible with better-sqlite3, but with opt-in promise API.
Please note that there is also the libSQL SDK, which is useful if you don't need better-sqlite3
compatibility or use libSQL in environments like serverless functions that require fetch()
-based database access protocol.
You can install the package with:
Node:
npm i libsql
Bun:
bun add libsql
Deno:
Use the npm:
prefix for package import:
import Database from 'npm:libsql';
To try out your first libsql program, type the following in hello.js
:
import Database from 'libsql';
const db = new Database(':memory:');
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);
console.log(`Name: ${row.name}, email: ${row.email}`);
and then run:
$ node hello.js
To use the promise API, import libsql/promise
:
import Database from 'libsql/promise';
const db = new Database(':memory:');
await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
await db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
const stmt = await db.prepare("SELECT * FROM users WHERE id = ?");
const row = stmt.get(1);
console.log(`Name: ${row.name}, email: ${row.email}`);
import Database from 'libsql';
const db = new Database('hello.db');
import Database from 'libsql';
const url = process.env.LIBSQL_URL;
const authToken = process.env.LIBSQL_AUTH_TOKEN;
const opts = {
authToken: authToken,
};
const db = new Database(url, opts);
import libsql
const opts = { syncUrl: "<url>", authToken: "<optional auth token>" };
const db = new Database('hello.db', opts);
db.sync();
db.exec("CREATE TABLE users (id INTEGER, email TEXT);")
db.exec("INSERT INTO users VALUES (1, 'alice@example.org')")
const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);
To build the libsql
package, run:
LIBSQL_JS_DEV=1 npm run build
You can then run the integration tests with:
export LIBSQL_JS_DEV=1
npm link
cd integration-tests
npm link libsql
npm test
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libSQL by you, shall be licensed as MIT, without any additional terms or conditions.
FAQs
A better-sqlite3 compatible API for libSQL that supports Bun, Deno, and Node
The npm package libsql receives a total of 118,931 weekly downloads. As such, libsql popularity was classified as popular.
We found that libsql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.
Product
Socket's Rubygems ecosystem support is moving from beta to GA, featuring enhanced security scanning to detect supply chain threats beyond traditional CVEs in your Ruby dependencies.
Research
The Socket Research Team investigates a malicious npm package that appears to be an Advcash integration but triggers a reverse shell during payment success, targeting servers handling transactions.