Internet
Seminar

Fall 2021
course
site
-->

Thu Nov 11

Prelude : covid, zoom, and all that - today's protocol.

First : let's discuss the homework. Anything you'd like to go over about SQL - concepts or how it works?

Second : a look at how to use SQL from python.

Here are some of the concepts

The overview in the python docs gives a nice summary.

It is often important to handle transactions correctly - the data exists both in memory and in the database, and if you're not careful the two can get out of sync.

As your project gets bigger, it can make sense to put in an abstraction layer between the database SQL code and your top-level program code - that is typically done with an "ORM" library. There are both advantages and disadvantages, as per this ORM for Python discussion.

Django, another python web back end, has its own built-in ORM.

Two other popular ones are

I'm using peewee in my flask umber course content app - I'll show a bit of that code in class. For example, the peewee ORM object model is in model.py

flask

Our next (and last) technology is flask, which we'll discuss next week, and in the following weeks use to build a web project that incorporates as many of the ideas we've been discussing as we can cram in. ;)

Flask has much better debugging tools than the backend-only stuff we've been doing, at the cost of some complexity in managing both a local development and remote deployed environment.

concepts:

This digital ocean tutorial is a good walkthrough of a flask app - including the virtual environment.

For next week, please work through that example. I will start during class if there's time.


I've attached a few of the python files we used in class.

And you can find a link to a video recording of today's class on the videos page.

https://cs.bennington.college /courses /fall2021 /internet /notes /11-11
last modified Thu November 11 2021 3:28 pm

attachments [paper clip]

  last modified size
TXT decorator.py Thu Nov 11 2021 03:17 pm 320B
TXT demo.py Thu Nov 11 2021 03:17 pm 140B