Setup Guide for Students
Getting Started with SQL Homework
Choose Your Setup PathΒΆ
There are two ways to work on assignments. Option A is strongly recommended.
| Option A β Coder (recommended) | Option B β Local install | |
|---|---|---|
| Setup time | ~5 minutes | 20β30 minutes (PostgreSQL install) |
| PostgreSQL | Pre-installed and running | You install it |
| Works on | Any browser | Mac, Linux, Windows |
| Internet required | Yes | No (after setup) |
β Option A β Use Coder (Recommended)ΒΆ
Coder gives you a fully configured VSCode environment in your browser β PostgreSQL is already installed, running, and the database is pre-loaded for each assignment. No installation required.
Step A1 β Open the WorkspaceΒΆ
Go to coder.cs.calvin.edu
Log in with your Calvin credentials
Make sure PostgreSQL module is running
Open your workspace (or create one if prompted)
Click Open in VS Code β this launches a full VSCode session in your browser with everything already configured
Step A2 β Accept the AssignmentΒΆ
Click the invitation link your instructor shared
Click Accept this assignment
Wait a few seconds, then refresh the page
Click the link to your newly created repository
Copy the repository URL (green Code button β copy HTTPS URL)
Step A3 β Clone the RepositoryΒΆ
Open the terminal inside the Coder VSCode session and run:
git clone https://github.com/[YOUR-REPO-URL-HERE]
cd [HOMEWORK-NAME]
code .Step A4 β Set Up PythonΒΆ
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtYou should see (venv) at the start of your terminal prompt.
Important: Activate the virtual environment every time you open a new terminal window before running any Python commands.
Step A5 β Install SQLTools ExtensionsΒΆ
You need two VSCode extensions to connect to the database:
Open the Extensions panel (
Ctrl+Shift+X/Cmd+Shift+X)Search for SQLTools and install it
Search for SQLTools PostgreSQL/Cockroach Driver and install it
Reload VSCode when prompted
Step A6 β Connect VSCode to the DatabaseΒΆ
Click the SQLTools icon in the VSCode left sidebar (looks like a database cylinder)
Click Add New Connection
On the Select your database driver screen, click PostgreSQL
Fill in the connection form:
Connection name: CS354
Server: localhost
Port: 5432
Database: [DATABASE NAME] β provided in the assignment README
Username: admin
Password: adminClick Test Connection to confirm it works, then Save Connection
The connection will appear in the sidebar β click it to connect
A green checkmark confirms you are connected
The database is already populated with data. Skip straight to writing queries.
Step A7 β ContinueΒΆ
Jump to Step 7 β Explore the Database below. The remaining steps are identical for both options.
π» Option B β Local InstallΒΆ
Use this option if you prefer to work offline or already have PostgreSQL installed.
Step B1 β Install ToolsΒΆ
| Tool | What it is | Download |
|---|---|---|
| PostgreSQL 16 | The database engine | See below |
| Git | Version control to submit your work | git-scm.com |
| VSCode | Code editor | code |
| SQLTools | VSCode extension to run SQL queries | Install from VSCode marketplace |
| SQLTools PostgreSQL Driver | Connects SQLTools to PostgreSQL | Install from VSCode marketplace |
| Python 3.10+ | Runs the grader locally | python.org |
Note for Windows users: After installing Git, use Git Bash as your terminal for all commands in this guide.
Step B2 β Install PostgreSQLΒΆ
Mac:
brew install postgresql@16
brew services start postgresql@16Add PostgreSQL to your PATH (add this line to ~/.zshrc or ~/.bash_profile):
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"Then reload your shell:
source ~/.zshrcLinux (Ubuntu/Debian):
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresqlWindows:
winget install PostgreSQL.PostgreSQL.16After installation, verify PostgreSQL is running:
psql --versionYou should see something like psql (PostgreSQL) 16.x.
Step B3 β Accept the AssignmentΒΆ
Click the invitation link your instructor shared
Click Accept this assignment
Wait a few seconds, then refresh the page
Click the link to your newly created repository
Copy the repository URL (green Code button β copy HTTPS URL)
Step B4 β Clone the RepositoryΒΆ
git clone https://github.com/[YOUR-REPO-URL-HERE]
cd [HOMEWORK-NAME]
code .Step B5 β Set Up PythonΒΆ
Mac / Linux:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtWindows:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txtImportant: Activate the virtual environment every time you open a new terminal window before running any Python commands.
Step B6 β Connect VSCode to the DatabaseΒΆ
Click the SQLTools icon in the VSCode left sidebar
Under Connections, you should see a connection already listed
Click it to connect β a green checkmark confirms success
If the connection does not appear automatically:
SQLTools sidebar
β Add new connection
β PostgreSQL
β Fill in:
Host: localhost
Port: 5432
Database: [DATABASE NAME]
Username: admin
Password: admin
β Save connectionStep 7 β Explore the DatabaseΒΆ
Before writing queries, take a moment to understand the data.
In the SQLTools sidebar, expand your connection to see the tables. Click any table to see its columns.
You can also run a quick exploration query β open any .sql file,
type the following, and press the Run button:
-- See all tables
SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public';-- Preview a table (replace 'students' with any table name)
SELECT * FROM students LIMIT 5;Step 8 β Write Your QueriesΒΆ
Each question has its own .sql file (e.g. q1.sql, q2.sql).
Open a question file. You will see something like this:
-- ============================================================
-- Question 1 (10 points)
-- List the name and GPA of all students with a GPA above 3.5
-- Order results by GPA descending
--
-- Expected columns: name, gpa
-- ============================================================
-- Write your query below:Write your query below the comment block:
-- Write your query below:
SELECT name, gpa
FROM students
WHERE gpa > 3.5
ORDER BY gpa DESC;To run the query, open the VSCode command bar with
Ctrl+Shift+P (Windows/Linux) / Cmd+Shift+P (Mac),
then type SQLTools and select SQLTools: Run Selected Query
(or Run Current Query if nothing is selected).
You can also use the shortcut Ctrl+E Ctrl+E (Windows/Linux) /
Cmd+E Cmd+E (Mac) once SQLTools is connected.
Results appear in a panel at the bottom of the screen.
Step 9 β Check Your Score LocallyΒΆ
Before submitting, run the grader to see how many questions you have correct:
python grade.pyOn your first run, the grader will automatically create and populate the database for you β no setup step required:
Database not found β creating and loading data...
β
q1: correct (10 pts)
β q2: incorrect (0 pts)
β
q3: correct (10 pts)
π₯ q4: error β syntax error at or near "FORM" (0 pts)
β¬ q5: empty file (0 pts)
Score: 20/50On subsequent runs the database already exists and it starts grading immediately.
Fix any issues and run grade.py again until you are happy with your score.
Step 10 β Submit Your WorkΒΆ
When you are ready to submit:
git add .
git commit -m "completed homework"
git pushGitHub Actions will automatically run the grader on your submission.
To see your results:
Go to your repo on GitHub
β Click the Actions tab
β Click the most recent workflow run
β See β
or β per question and your total scoreYou can push as many times as you want before the deadline. Each push triggers a new grading run.
Resetting the DatabaseΒΆ
The database is created automatically the first time you run grade.py.
You only need to reset it if you accidentally modified the data with
INSERT, UPDATE, or DELETE and want to start fresh.
Option A (Coder): Contact your instructor to have the database reloaded.
Option B (Local):
bash reset.shThis drops the database entirely and recreates it from scratch with the original schema and seed data.
Common ProblemsΒΆ
Cannot connect to the database in SQLTools (Option A β Coder)ΒΆ
If you see βNo connections foundβ, the connection needs to be created manually β follow Step A6 above. Make sure your Coder workspace is running before connecting. If Test Connection fails, try refreshing the page and reopening the workspace.
Cannot connect to the database in SQLTools (Option B β Local)ΒΆ
Make sure PostgreSQL is running and the admin role exists:
# Mac (Homebrew)
brew services start postgresql@16
# Linux
sudo systemctl start postgresql
# Windows β open the Services panel and start "postgresql-x64-16"If you get an authentication error, the admin role may not exist yet.
Ask your instructor or create it manually:
psql -U postgres -c "CREATE ROLE admin WITH LOGIN PASSWORD 'admin' SUPERUSER;"pip install failsΒΆ
Make sure your virtual environment is activated β you should
see (venv) in your terminal prompt. If not:
source venv/bin/activate # Mac/Linux/Coder
venv\Scripts\activate # Windowspython grade.py says βconnection refusedβ (Option B)ΒΆ
PostgreSQL is not running β grade.py cannot auto-create the database
without a running server. Start it first:
# Mac (Homebrew)
brew services start postgresql@16
# Linux
sudo systemctl start postgresql
# Windows β open the Services panel and start "postgresql-x64-16"Then run python grade.py again.
I get π₯ syntax error on a questionΒΆ
There is a SQL syntax error in your query. Read the error message
carefully β it usually tells you exactly where the problem is.
Common mistakes: typo in a keyword (FORM instead of FROM),
missing comma between column names, missing semicolon at the end.
I accidentally pushed with empty query filesΒΆ
No problem β just write your queries and push again. Each push creates a new grading run.
Quick ReferenceΒΆ
| Task | Option A (Coder) | Option B (Local) |
|---|---|---|
| Open environment | coder.cs.calvin.edu | Open VSCode locally |
| Database setup | Automatic on first python grade.py β
| Automatic on first python grade.py β
|
| Reset database (if data modified) | Contact instructor | bash reset.sh |
| Activate venv | source venv/bin/activate | same (Mac/Linux) / venv\Scripts\activate (Win) |
| Check your score | python grade.py | python grade.py |
| Submit | git add . && git commit -m "msg" && git push | same |
Getting HelpΒΆ
Use the feedback pull request on your repo to ask your instructor questions
Bring specific error messages to office hours or tutoring sessions
Check the Actions tab on GitHub for detailed grading logs
Good luck! π