Requires Go 1.20+.
cd minidb
go build -o minidb ./cmd/minidbTo ensure everything is working correctly:
go test ./...Start the database in interactive mode:
./minidbYou will see the prompt minidb>.
Example Session:
minidb> INSERT INTO users VALUES (1, 'Alice')
minidb> INSERT INTO users VALUES (2, 'Bob')
minidb> SELECT * FROM users WHERE id = 1
[1 Alice]
(1 rows)
minidb> FLUSH
MemTable flushed to SSTable
minidb> exitStart the database as a server:
./minidb -server -port 3000Connect using a TCP client like nc:
nc localhost 3000
INSERT INTO users VALUES (10, 'Remote')
SELECT * FROM usersData is stored in the ./data directory within the working folder.
wal.log: Write-Ahead Log.*.sst: Compacted data files.
To reset the database, simply delete the ./data directory.