← All drillsPersist It: A Database Behind Your API
What you'll be able to do- ✓Explain what a database gives a service that variables held in memory cannot
- ✓Model tables, keys and relationships as SQLAlchemy classes, and use the engine and the session
- ✓Change a live database with Alembic migrations, and prove each one against the data and in reverse
- ✓Store money as whole cents instead of decimal floats
- ✓Count the queries a piece of code sends, and find and fix the N+1 problem
- ✓Read a query plan, add an index with a migration, and avoid the function-on-a-column mistake
- ✓Make a group of changes all-or-nothing with a transaction
- ✓Add constraints that the database itself enforces, and check that they really are enforced
- ✓Reproduce a lost-update race with threads, and fix it with one atomic statement
Put a service on a real database, change its shape without losing data, find and fix its slow queries, and keep its data correct when things fail and when many users act at once.
⌁ Every application that keeps state: shops, bookings, banking, accounts. Migrations, indexes, transactions and constraints are the everyday toolkit of backend teams, on PostgreSQL, MySQL or SQLite.
Start this internshipCreate an account to unlock the 5 sections, the workbench, and askThili.
BeginSections
1. Persist It: A Database Behind Your API
🔒 locked2. Lesson 1 - Model the Data
🔒 locked3. Lesson 2 - Change It Safely
🔒 locked4. Lesson 3 - Make It Fast
🔒 locked5. Lesson 4 - Keep It Correct
🔒 lockedDig deeper
🔗SQLAlchemy 2.0 documentation
docs🔗SQLAlchemy ORM quick start
docs🔗Alembic tutorial
docs🔗Alembic: running batch migrations for SQLite
docs🔗SQLite: the query planner
docs🔗SQLite: foreign key support
docs🔗SQLite: transactions
docs🔗PostgreSQL: concurrency control
docs🔗Python sqlite3 module
docs