Registry / database / sql-tools

sql-tools

JSON →
library0.1.7jsnpmunverified

sql-tools provides OLAP functionality (cube, rollup) for SQL engines that lack native OLAP support, transforming standard SQL queries into aggregated result sets. Version 0.1.7 is a pre-1.0 release (stability: designing) with irregular release cadence. Its key differentiator is generating SQL that works on any database without requiring OLAP extensions, unlike dedicated OLAP libraries. Includes additional SQL utility functions.

npm install sql-tools
INSTALL
IMPORT
SIG · SQL-TOOLS
S
sql-tools
databasejavascriptv0.1.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

olap
import { olap } from 'sql-tools'
const olap = require('sql-tools').olap
ESM import is preferred; require works but TypeScript may need esModuleInterop.
cube
import { cube } from 'sql-tools'
const { cube } = require('sql-tools')
cube is a named export; default export is not available.
olap
import { olap } from 'sql-tools'
import olap from 'sql-tools'
Default import does not exist; must use named import.

Shows basic usage of olap.cube to generate an aggregated SQL with totals for a given grouping column.

import { olap } from 'sql-tools'; const varsDef = [ { name: 'zone', place: 'left', aggLabel: '=SUM=' }, { name: 'kind', place: 'left' }, { name: 'sales', place: 'data' }, { name: 'calif', place: 'data', aggExp: 'min(calif)' } ]; const sqlTotal = olap.cube('SELECT * FROM sales', 'zone', varsDef); console.log(sqlTotal);
Debug
Known issues
gotchaThe package is in 'designing' stability; API may change without notice.
fix
Pin to exact version and monitor releases for breaking changes.
affects: <1.0.0
gotchaolap.cube does not validate input; invalid field definitions can produce malformed SQL.
fix
Ensure all varsDef objects have 'name' and 'place' fields; 'aggLabel' is required for 'left' fields.
affects: >=0.0.0
deprecatedUsing require() syntax may not work in TypeScript without esModuleInterop.
fix
Use ESM import syntax.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: olap.cube is not a function
Incorrect import: got the default export instead of the named export.
fix
Use import { olap } from 'sql-tools' or const olap = require('sql-tools').olap.
Cannot find module 'sql-tools'
Package not installed or import path is wrong.
fix
Run npm install sql-tools and ensure the import is correct.
SQL syntax error near 'WITH "olap cube" AS'
The generated SQL uses CTEs which may not be supported by older databases.
fix
Check database compatibility; use a database that supports WITH (CTE) syntax.
Upgrade
Version history
0.1.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
sql-tools — npm install sql-tools · libregistry