Turing Guild Labs

Back to course

Lab

Lab: Let Codex Build Your Habitat SQLite Database

Submit this lab

Lab: Let Codex Build Your Habitat SQLite Database

Objective

Use Codex to turn your habitat JSON file into a working SQLite database, then update your Habitat CLI so it uses SQLite instead of JSON.

Success Criteria

  • Create a dedicated lab folder for this Codex-built SQLite project.
  • Add your previous Habitat CLI project files and original habitat JSON file.
  • Prompt Codex to design and build a SQLite database from your JSON.
  • Prompt Codex to update your CLI so it reads and writes habitat data using SQLite instead of JSON.
  • Verify that Codex created a local SQLite database file.
  • Inspect the schema and query results Codex produced.
  • Test your Habitat CLI after the migration.
  • Give Codex any CLI errors you find and let it fix them.
  • Explain how Codex represented your objects and at least one relationship.
  • Submit a public GitHub repository URL for your completed lab.

Instructions

  1. Open Codex.

  2. Create a new Codex project for this lab.

When Codex asks you to choose a folder, create or select this lab folder inside your course labs folder:

~/labs/habitat-sqlite-codex

If your labs folder does not exist yet, create it when choosing the project folder. The goal is for this lab project to live at:

labs/habitat-sqlite-codex
  1. Add your previous Habitat CLI project files to this lab folder from the command line.

Use terminal commands to copy the files from your previous Habitat CLI lab into this lab folder. This should include your CLI source code, package files, and original habitat JSON file.

Do not use Finder or File Explorer for this step. If you have forgotten how to copy folders, copy files, or check folder contents from the command line, ask ChatGPT to remind you.

  1. Ask Codex to build the SQLite database and connect your CLI to it.

Use this prompt in Codex:

I have copied my previous Habitat CLI project files into this project folder, including my habitat JSON file.

Please inspect the CLI code and the JSON file. Then migrate this project so the CLI uses SQLite instead of JSON for storage.

Requirements:

1. Use the JSON file as the source of truth.
2. Create a SQLite database file named habitat.db.
3. Create tables for the major object types in the JSON.
4. Represent at least one relationship between objects, such as an airlock connected to doors.
5. Insert data from the JSON into the database.
6. Update the Habitat CLI so its commands read from and write to habitat.db instead of the JSON file.
7. Preserve the existing CLI behavior as much as possible. The commands I already built should still work.
8. Create a schema.sql file that shows the database schema.
9. Create a query-results.txt file with at least three useful SELECT query results.
10. Create a cli-test-results.txt file showing the CLI commands you ran to test the migrated CLI and what happened.
11. Create a codex-build-notes.md file explaining what tables you created, what relationship you represented, what CLI storage code you changed, and how I can verify the database and CLI.

Please do the implementation work for me. Do not just explain what I should type. After you build it, summarize what files you created or changed, what CLI commands I should test, and what I should inspect.
  1. Let Codex work.

Codex may create a script, run SQLite commands, install a SQLite package, or update your CLI code directly. Let it choose a reasonable implementation.

If Codex asks for permission to run safe local commands in this project folder, approve those commands.

  1. Inspect what Codex created and changed.

Your lab folder should include:

habitat.db
schema.sql
query-results.txt
cli-test-results.txt
codex-build-notes.md

It should also include your original habitat JSON file and your migrated Habitat CLI source code.

  1. Read schema.sql.

Look for the table names Codex created. Make sure they match the objects from your JSON file.

Also look for how Codex represented relationships between objects.

  1. Read query-results.txt.

The file should show output from at least three useful database queries.

If the results are empty, ask Codex to investigate whether the data was inserted correctly.

  1. Test your migrated Habitat CLI.

Use the same kinds of CLI commands you used in your previous Habitat CLI lab.

Your goal is to answer two questions:

  • Does the database Codex built differ from the database you created in the previous SQLite lab?
  • Does your Habitat CLI still work now that it uses SQLite instead of JSON?

If your CLI command fails, copy the full error message and give it back to Codex. Ask Codex to fix the problem, then test the CLI again.

Keep going until your main CLI commands work or Codex clearly explains what is still broken.

  1. Write your own reflection.

Create a file named student-reflection.md.

In that file, answer these questions:

1. What tables did Codex create from your JSON file?
2. What relationship did Codex represent in the database?
3. What file did you inspect to understand the database schema?
4. What query result helped you trust that the data was actually inserted?
5. Did Codex's database design differ from the database you created in the previous SQLite lab? If so, how?
6. Which CLI commands did you test after Codex connected the CLI to SQLite?
7. Did your CLI still work? If not, what error did you give back to Codex, and how did Codex fix it?
8. What did Codex do for you in this lab that you did manually in the previous SQLite lab?

Required Deliverables

Your GitHub repository must include:

  • Your migrated Habitat CLI source code.
  • Your original JSON file from the previous lab.
  • habitat.db, the SQLite database Codex created.
  • schema.sql, the exported database schema.
  • query-results.txt, showing results from at least three SELECT queries.
  • cli-test-results.txt, showing the CLI commands Codex or you used to test the migrated CLI.
  • codex-build-notes.md, explaining Codex's implementation.
  • student-reflection.md, with your own answers to the reflection questions.
  • A public GitHub repository URL submitted to the LMS.

Submit Your Lab With GitHub

Before you submit, make sure you are inside your lab directory. The path should end with:

labs/habitat-sqlite-codex

Initialize Git, commit your work, create a public GitHub repository, and push it:

git init
git add .
git commit -m "Complete Codex habitat SQLite lab"
gh repo create habitat-sqlite-codex --public --source=. --remote=origin --push

Get the URL for your GitHub repository:

gh repo view --web

Copy the GitHub repository URL from your browser and submit that URL with your lab submission.