Putting It All Together

Full Stack Foundations >> Working with Crud >> Putting It All Together


Troubleshooting advice:

We are running python database_setup.py IN VAGRANT. Here is how to do that:

Step 1: Put your database_setup.py file inside fullstack/vagrant/new_folder_for_this_project (we used this directory within the last course, Relational Databases, minus the new folder we are adding special for this new database_setup.py file) so it looks like this:



Step 2: Within Terminal (aka your UNIX command line, given you are using a Mac)

cd into fullstack/vagrant

run: vagrant up

run: vagrant ssh

once in virtual machine…

cd /vagrant/fullstack/new_folder_you_just_made

run: python database_setup.py


Then the new folder you made should open and show a new file called restaurantmenu.db within it alongside database_setup.py.


Good job!






Intro to Relational Databases >> Deeper into SQL >> Subqueries


1. https://www.techonthenet.com/sql/exists.php

This website better explains the EXISTS statement and how to convert a casual statement into a query.


EXISTS Example (the bolded text is the SQl code explained in plain English, not to be included in actual SQL query):


SELECT * 1) find all of the records

FROM customers 2) from the customers table

WHERE EXISTS   3) where there is at least 1 record


FROM orders   4) in the orders table

WHERE customers.customer_id = orders.customer_id); 5) with the same customer_id


2. http://www.w3resource.com/sql/subqueries/nested-subqueries.php

This shows visual representation of how to think about queries and subqueries. very helpful for understanding

Screen Shot 2016-10-11 at 11.54.19 AM.png

Intro to Relational Databases >> Python DB-API >> Deleting the Spam


Again we go into the terminal while server is running, and input:

  1. Control – C
  2. psql forum
  3. delete from posts where content like ‘%Cheese%’;
  4. OUTPUT (don’t input this, this is what you will see as output in your terminal): DELETE (and some random number)
  5. Control – D
  6. python forum.py

Now if you reload localhost:8000 you will see your changes, aka all cheese posts deleted.


Quiz: Updating Away the Spam

Intro to Relational Databases >> Python DB-API >> Quiz: Updating Away the Spam

Troubleshooting where to input the code:

The code is entered into terminal, not into the actual code itself.

So if your server is up and running (you are able to view your page at localhost:8000), then within terminal, input these commands:

  1. Control – C
  2. psql forum
  3. update posts set content = ‘Cheese’ where content like ‘%spam%’;
  4. OUTPUT (do not type, this is what you will see as output): UPDATE [some number]
  5. Control – D
  6. python forum.py


You will be able to see your changes if you reload your localhost:8000 page.