Socket
Book a DemoInstallSign in
Socket

alasql

Package Overview
Dependencies
Maintainers
2
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alasql

Use SQL to select and filter javascript data - including relational joins and search in nested objects (JSON). Export to and import from Excel and CSV

latest
Source
npmnpm
Version
4.6.6
Version published
Weekly downloads
178K
4.53%
Maintainers
2
Weekly downloads
 
Created

What is alasql?

AlaSQL is a JavaScript library that provides a SQL-like syntax for querying and manipulating data in the browser and Node.js. It allows you to perform SQL operations on JavaScript arrays, JSON objects, and other data formats without needing a database server.

What are alasql's main functionalities?

In-memory SQL Database

AlaSQL can be used to perform SQL queries on in-memory data structures like arrays and JSON objects. This example demonstrates selecting records from an array of objects using SQL syntax.

const alasql = require('alasql');
const data = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}];
const result = alasql('SELECT * FROM ? WHERE id = 1', [data]);
console.log(result);

CSV and Excel File Processing

AlaSQL can read and write CSV and Excel files, allowing you to perform SQL operations on data stored in these formats. This example shows how to read data from a CSV file.

alasql('SELECT * FROM CSV("data.csv", {headers:true})', [], function(res) {
  console.log(res);
});

LocalStorage and IndexedDB Support

AlaSQL can store and retrieve data from browser storage solutions like LocalStorage and IndexedDB. This example demonstrates storing a table in LocalStorage.

alasql('CREATE TABLE test (id INT, name STRING)');
alasql('INSERT INTO test VALUES (1, "Alice"), (2, "Bob")');
alasql('SELECT * INTO localStorage FROM test');

Advanced SQL Features

AlaSQL supports advanced SQL features such as GROUP BY, JOIN, and more. This example shows how to use the GROUP BY clause to aggregate data.

alasql('SELECT name, COUNT(*) AS count FROM ? GROUP BY name', [data]);

Other packages similar to alasql

Keywords

SQL

FAQs

Package last updated on 02 Apr 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.