🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

duckdb

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duckdb

DuckDB node.js API

1.3.0
latest
Version published
Weekly downloads
185K
36.55%
Maintainers
3
Weekly downloads
 
Created

What is duckdb?

The duckdb npm package provides a fast, in-process SQL OLAP database management system. It is designed for analytical query workloads and can be embedded in applications to perform complex queries on large datasets efficiently.

What are duckdb's main functionalities?

In-Memory Database

This feature allows you to create and manipulate an in-memory database. The code sample demonstrates creating a table, inserting data, and querying the data using SQL.

const duckdb = require('duckdb');
const db = new duckdb.Database(':memory:');
const connection = db.connect();
connection.run('CREATE TABLE test (id INTEGER, name STRING);');
connection.run("INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob');");
connection.all('SELECT * FROM test;', (err, res) => {
  if (err) throw err;
  console.log(res);
});

File-Based Database

This feature allows you to create and manipulate a file-based database. The code sample shows how to create a database file, create a table, insert data, and query the data.

const duckdb = require('duckdb');
const db = new duckdb.Database('mydb.duckdb');
const connection = db.connect();
connection.run('CREATE TABLE test (id INTEGER, name STRING);');
connection.run("INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob');");
connection.all('SELECT * FROM test;', (err, res) => {
  if (err) throw err;
  console.log(res);
});

Efficient Query Execution

DuckDB is optimized for analytical queries. This code sample demonstrates executing an aggregate query to calculate the average value from a table.

const duckdb = require('duckdb');
const db = new duckdb.Database(':memory:');
const connection = db.connect();
connection.run('CREATE TABLE test (id INTEGER, value DOUBLE);');
connection.run('INSERT INTO test VALUES (1, 10.5), (2, 20.5), (3, 30.5);');
connection.all('SELECT AVG(value) AS average_value FROM test;', (err, res) => {
  if (err) throw err;
  console.log(res);
});

Other packages similar to duckdb

FAQs

Package last updated on 03 Jun 2025

Did you know?

Socket

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.

Install

Related posts