A Node.js-based SQL engine that can parse and execute SQL queries (SELECT, INSERT, UPDATE, DELETE) directly on CSV files. Supports WHERE clauses with AND/OR/grouping, JOINs, aggregation, and more—all from the command line or an interactive shell.
- Run SQL queries (SELECT, INSERT, UPDATE, DELETE) on CSV files
- WHERE clause with AND, OR, and parentheses (grouping)
- JOIN support (INNER, LEFT, RIGHT)
- Aggregation: COUNT, SUM, AVG, MIN, MAX
- ORDER BY, GROUP BY, LIMIT, DISTINCT
- Interactive shell and CLI with colored output and help
- Clone this repository:
git clone <repo-url> cd SQL-Query-Parser
- Install dependencies:
cd SQL-Query-Parser npm install
Run the CLI:
node src/cli.js
- Type SQL commands or
exit
to quit. - Type
--help
for usage instructions.
Run the interactive shell:
node src/outputs.js
- Type SQL commands or
exit
to quit. - Type
--help
for usage instructions.
SELECT fields FROM table [WHERE ...] [ORDER BY ...] [GROUP BY ...] [LIMIT ...] [DISTINCT]
INSERT INTO table (col1, col2) VALUES (val1, val2)
UPDATE table SET col1 = val1 WHERE ...
DELETE FROM table WHERE ...
- WHERE supports AND, OR, parentheses, =, !=, >, <, >=, <=, LIKE
- JOINs: INNER, LEFT, RIGHT
- Aggregates: COUNT, SUM, AVG, MIN, MAX
SELECT name, age FROM student WHERE (age > 18 AND grade = 'A') OR (name = 'John')
INSERT INTO student (id, name, age) VALUES (3, 'Alice', 22)
UPDATE student SET grade = 'B' WHERE score > 80
DELETE FROM student WHERE age < 18 OR grade = 'F'
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
- Fork the repo and create your branch.
- Make your changes and add tests if needed.
- Submit a pull request.
MIT