Last Updated: June 6, 2026
With a connection in hand, the actual work begins: running SELECT, INSERT, UPDATE, and DELETE statements from Python. The DB-API provides two methods (execute and executemany), three ways to read results (fetchone, fetchall, fetchmany), and a transaction model that decides whether writes survive a crash. This lesson covers all of that, plus the patterns that come up often: bulk inserts, getting back the id of a row that was just inserted, paginating large result sets, and building dynamic queries without falling into SQL injection.