This was adapted from BU Data Science Association's Spring 2025 Workshop, which was adapted from Pamela Fox
This is a Python web app using the Flask framework and a Postgres database
- It can be used as a playground for testing SQL queries
Preferably, this is used in a DevContainer with Docker. (not on GitHub Codespaces)
-
Download this project from GitHub and put it on your local computer.
-
On your local IDE, get a DevContainer running. On VSCode, a pop-up should appear if you have the right extensions downloaded. If not, go to the left-hand side and click on the "Remote Explorer." icon that looks like a computer monitor, and then start the DevContainer.
-
Run
python3 data_utils.py -
Open the terminal and run
python3 -m flask runto get Flask started. -
Go to your browser and go to
http://localhost:5000to see the web app running. You may get a warning because the link is not https. -
You should be all set! Try modifying the SQL commands under the TODOs in app.py and notice how the results change.
If you have issues, navigate to bottom of the screen and look at your ports. You may have ports set to private that need to be public.
-
Open the project on Codespaces.
-
Wait for SQLTools extension to load on the left navbar of VS Code
-
Connect to the postgres database in the SQLTools menu (the cylinder) - if this does not work by default, the connection info is in the .env file
-
There should be a container database tab from SQLTools, you can type in a query and press
Run on Active Connectionto see the result -
Run
python3 -m flask runto start the flask server -
Go to the
portstab in the VS Code console, and right click on port 5000. Changeport visibilityto public -
Open the link to port 5000 and try out the flask app
- Note that Github Copilot is automatically installed and offers terrible suggestions. If this is a problem you can disable it in extensions