A lightweight, C++17-based SQL engine built for learning and experimentation.
Supports basic SQL operations: CREATE, INSERT, SELECT, UPDATE, DELETE, DROP with simple WHERE conditions.
- Table creation with
INTandTEXTcolumns - CRUD operations (Insert, Select, Update, Delete)
- Condition filtering (
=,<,>,>=,<=) - Command-line interface with history (
.exitto quit)
Clone the repo and build with CMake:
git clone https://github.com/your-username/NanoSQL.git
cd NanoSQL
mkdir -p build && cd build
cmake ..
make
This produces the executable nanosql (and test binaries test_lexer, test_parser, test_condition).
▶️ Usage
Start the database:
bash
./nanosql
You'll see a prompt:
text
nanosql>
Example session
sql
CREATE TABLE users (id INT, name TEXT, age INT);
INSERT INTO users VALUES (1, 'Alice', 30);
INSERT INTO users VALUES (2, 'Bob', 25);
INSERT INTO users VALUES (3, 'Charlie', 35);
SELECT * FROM users;
-- id | name | age
-- 1 | Alice | 30
-- 2 | Bob | 25
-- 3 | Charlie | 35
SELECT name, age FROM users WHERE age > 28;
-- name | age
-- Alice | 30
-- Charlie | 35
UPDATE users SET age = 31 WHERE id = 1;
DELETE FROM users WHERE id = 3;
DROP TABLE users;
.exit
📦 Supported Data Types
INT – integer numbers
TEXT – string values (use single quotes: 'hello')
🧪 Running Tests
After building, run the test executables:
bash
./test_lexer
./test_parser
./test_condition
📄 License
MIT – feel free to use and modify.
Built as a learning project – happy querying! 🎉