build-a-sql-database / lesson-08.md
Lesson 08 · In-memory tables

Demo: printing a result set

Time to see your engine work end to end. Today you format a result set as a text grid and drive the whole stack by hand - create a table, insert rows, scan, and print.

The goal

Format a result set as an aligned text grid with a header row, and print the result of a hand-built query.

Start here - the target
TO DO
Scenario: Rendering a result set as a text grid
Givena result set with columns [id, name] and rows [1, "alice"] and [2, "bob"]
Whenthe result set is formatted as a grid
Thenthe first line is "id | name"
Andthe following lines are "1 | alice" and "2 | bob"
Background

Everything so far has been parts; today they run together. A formatter turns a result set into text a person can read: a header line of column names, then one line per row, values separated by a divider. Keep it simple - a single-space " | " separator is enough to make the output legible.

Wire it into a tiny main that builds the users table, inserts a couple of rows, scans it, and prints the grid. That hand-written driver is your walking skeleton: proof the value, row, schema, table, database, scan, and formatter all fit. From here the SQL front-end will replace the hand-built parts one at a time, but the pipeline it feeds is already alive.

Make it work
func Format(rs ResultSet) string {
// join column names with " | " for the header
// then each row's values rendered the same way, one line each
}
// in main(): create users, insert two rows, print Format(Scan(users))
CheckpointDONE
You can create a table, insert rows, scan them, and print a formatted result - the whole first chapter runs. Commit and stop here.