Skip to content

Sep 30: SSH Tunnel, venv, Faker

Learning Objectives

After today's class, you should be able to:

  • Configure an SSH tunnel for connecting to the database server.
  • Create a Python virtual environment and install packages using pip.
  • Create and fill tables using the Python faker module.

Lesson Outline

SSH Tunnel [15 min]

Python venv [15 min]

  • Open your CS374 folder in VS Code
    • Ideally your project repository folder is below the CS374 folder
  • From the command pallette (press F1)
    • Python: Create Environment…
    • Venv (in current workspace)
  • Open a terminal in VS Code
    • Windows users should use "Git Bash" as their shell in VS Code.
      • That way, the commands will be the same as on Linux and macOS.
    • Your prompt should begin with (.venv)
      • If it doesn't, run the command source .venv/bin/activate
    • Run the following commands:
      pip install --upgrade pip
      pip install "psycopg[binary]"
      pip install faker
      

Faker module [20 min]

Hotel database diagram

Activity [25 min]

Your To-Do List

  • Read about psycopg and faker and take the reading quiz (TBD)
  • Be prepared to discuss your project with your instructor at your team's Thursday meeting.
    • Be sure that your proposal, EER model, and relational model are all in sync with one another.
  • Definitely get started on HW3 either today or tomorrow! (due Monday)
  • Midterm exam: next Thursday, Oct 9th in class