Databases with sqlite3: first steps
Almost every application stores data: users, orders, grades, messages. A database stores them in an orderly way and lets you…
Learn to store and query data with a relational database without installing anything. In this lesson you will use the sqlite3 module to create tables and insert rows, query with SELECT (WHERE, ORDER BY, LIMIT), modify data with UPDATE and DELETE using safe parameters, group operations into transactions with commit and rollback, protect the data with constraints, and summarize and combine tables with GROUP BY, HAVING and JOIN.
Almost every application stores data: users, orders, grades, messages. A database stores them in an orderly way and lets you…
SELECT is the SQL command you will use the most. The examples in this article use this products table:
So far you have read data. To change it, INSERT , UPDATE and DELETE are used. But first, the most important security rule when…
A transaction groups several operations so that all or none are applied. It is what prevents a transfer from taking money out of…
The power of SQL lies in summarizing data and combining tables without writing loops in Python.
Create a Python program that stores contacts in an SQL table and queries them. Use an in-memory database with the sqlite3 module…
Create a Python program that selects, with a WHERE query, the products that cost at least a minimum price. Use an in-memory…
Create a Python program that groups sales by category with GROUP BY and the aggregate functions SUM and COUNT . Use an in-memory…
Create a Python program that modifies an inventory with UPDATE and DELETE , and shows how many rows each operation affects with…
Create a Python program that searches users by part of their name with LIKE without concatenating text into the SQL : always use…
Create a Python program that shows a ranking in pages using LIMIT and OFFSET in the query. Use an in-memory database with the…
Create a Python program that makes transfers between accounts inside a transaction : if something fails, no change is applied…
Create a Python program that relates two tables with LEFT JOIN and computes each customer's total, even if they have no orders…
Create a Python program that computes statistics per subject with AVG , MAX , MIN and GROUP BY , and discards small groups with…
Create a Python program that lets the database itself reject invalid data through constraints, catching sqlite3.IntegrityError …