# @mandel59/erq

> Erq - Easy Relational Query Language

Latest version **0.4.1** (published 2025-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mandel59/erq
pnpm add @mandel59/erq
yarn add @mandel59/erq
bun add @mandel59/erq
```

Provides the command `erq`.

## Health

**Score 60/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2025-11-12 |
| First published | 2024-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 17 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 12 |
| Author | Ryusei Yamaguchi |
| Maintainers | mandel59 |

## Links

- npm: https://www.npmjs.com/package/@mandel59/erq
- Repository: https://github.com/mandel59/erq
- Homepage: https://github.com/mandel59/erq#readme
- Issues: https://github.com/mandel59/erq/issues
- npm.io page: https://npm.io/package/@mandel59/erq

## Dependencies (17)

- [csv](https://npm.io/package/csv.md) ^6.3.11
- [vega](https://npm.io/package/vega.md) ^6.0.0
- [chalk](https://npm.io/package/chalk.md) ^5.4.1
- [jsdom](https://npm.io/package/jsdom.md) ^26.0.0
- [canvas](https://npm.io/package/canvas.md) ^3.1.0
- [ndjson](https://npm.io/package/ndjson.md) ^2.0.0
- [opendal](https://npm.io/package/opendal.md) ^0.47.7
- [vega-lite](https://npm.io/package/vega-lite.md) ^6.4.1
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.6.3
- [better-sqlite3](https://npm.io/package/better-sqlite3.md) ^12.4.1
- [topojson-client](https://npm.io/package/topojson-client.md) ^3.1.0
- [lodash.mergewith](https://npm.io/package/lodash.mergewith.md) ^4.6.2
- [command-line-args](https://npm.io/package/command-line-args.md) ^6.0.1
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^7.0.3
- [quickjs-emscripten](https://npm.io/package/quickjs-emscripten.md) ^0.31.0
- [@ungap/structured-clone](https://npm.io/package/@ungap/structured-clone.md) ^1.2.1
- [@mandel59/memoized-json-hash](https://npm.io/package/@mandel59/memoized-json-hash.md) ^0.2.0

## Recent versions

- 0.4.1 (latest) — 2025-11-12
- 0.3.1-rc.2 (rc) — 2025-09-03
- 0.4.0 — 2025-11-02
- 0.3.1 — 2025-09-03
- 0.3.0 — 2025-06-04
- 0.2.2 — 2025-04-16
- 0.2.1 — 2025-01-24
- 0.2.0 — 2025-01-22
- 0.1.6 — 2024-05-20
- 0.1.5 — 2024-04-01
- 0.1.4 — 2024-03-12
- 0.1.3 — 2024-03-12
- 0.1.2 — 2024-02-23
- 0.1.1 — 2024-02-18
- 0.1.0 — 2024-02-16

## README

# Erq - Easy Relational Query Language

## Introduction

Erq is an alternative query language for relational databases. It is designed to be easy to learn and use, while being as expressive and powerful as SQL.

I originally used SQLite to analyze my own kanji database. However, the verbose and cumbersome syntax of SQL prevented me from doing ad hoc analysis quickly. So I created Erq, which simplifies the syntax of SQL.

## Quickstart

See [Quickstart](./doc/quickstart.md) for installation instructions, CLI examples, and a minimal `.erq` script.

## Usage

Erq CLI works like SQLite CLI. You can use it to query SQLite databases.

Basically, you can use Erq CLI like this:

```shell
erq your_database.db <your_query.erq >your_output.txt
```

Or you can use it interactively:

```shell
erq your_database.db
```

## Debug Logging

Erq writes debug information to `stderr`. You can opt into specific groups by setting the `ERQ_DEBUG` environment variable to a space- or comma-separated list of categories.

Available categories include:

- `sql` – SQL statements generated during script execution or imports
- `script` – script-specific helpers such as loop conditions
- `import` – SQL emitted when loading external data sources
- `lifecycle` – parent/child process lifecycle events
- `ipc` – IPC messages (e.g. completer results)
- `stack` – stack traces for caught exceptions
- `preprocess` – interpolation details while expanding ERQ expressions
- `general` – legacy bucket that enables all historical debug output

You can combine categories (e.g. `ERQ_DEBUG=sql,stack`) or use `1`, `true`, or `all` to enable every debug message.

During an interactive session you can inspect or change the same setting with the `.debug` dot command, for example `.debug sql stack` to enable only SQL and stack trace logging or `.debug off` to disable it again.

## Dot Commands

Inside the interactive CLI you can enter dot-prefixed utility commands. Use `.help` to list them or `.help COMMAND` to see detailed usage. Tab completion now suggests dot command names as well as arguments such as `.format` modes or `.debug` categories.

## Syntax Comparison with SQL

See [Syntax Comparison with SQL](./doc/syntax-comparison.md).

---
_Source: https://npm.io/package/@mandel59/erq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
