liveBook · Manning

Database update

As explained in Build Python Web Apps with Streamlit

UPDATE is a SQL statement that changes column values in rows matching an optional condition.

Use UPDATE when an existing database row needs new values. The statement names the table, assigns a column value with SET, and can use WHERE to limit which rows change. section 8.2.4

Updating a haiku

This command adds an attribution prefix to the haiku whose haiku_id is 1: UPDATE haikus SET text = '[By Alice] ' || text WHERE haiku_id = 1;. A following SELECT confirms the changed text.

Treat the condition as an important safety check: it identifies the intended row instead of applying the change broadly. Verify the result with SELECT while developing.

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines UPDATE and works through one conditional text change, but does not develop transaction or concurrency internals.
Examples
Uses the haikus table to prefix Alice’s haiku text and inspect the resulting row.
What it assumes
Assumes basic SQL and access to a PostgreSQL database containing the target table and row.
What you can do after
Apply UPDATE in PostgreSQL and verify a targeted row change with SELECT.
How it connects
Connects UPDATE with SQL tables, WHERE conditions, SELECT queries, and CRUD operations.

Also explained in

Compare how 3 books explain database update →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.