SQLAlchemy 2.0 Documentation
- Previous: Working with Database Metadata
- Next: Using INSERT Statements
- Up: Home
- On this page:
Working with Data¶
In Working with Transactions and the DBAPI, we learned the basics of how to interact with the Python DBAPI and its transactional state. Then, in Working with Database Metadata, we learned how to represent database tables, columns, and constraints within SQLAlchemy using the MetaData and related objects. In this section we will combine both concepts above to create, select and manipulate data within a relational database. Our interaction with the database is always in terms of a transaction, even if we’ve set our database driver to use autocommit behind the scenes.
The components of this section are as follows:
Using INSERT Statements - to get some data into the database, we introduce and demonstrate the Core
Insertconstruct. INSERTs from an ORM perspective are described in the next section Data Manipulation with the ORM.Using SELECT Statements - this section will describe in detail the
Selectconstruct, which is the most commonly used object in SQLAlchemy. TheSelectconstruct emits SELECT statements for both Core and ORM centric applications and both use cases will be described here. Additional ORM use cases are also noted in the later section Using Relationships in Queries as well as the ORM Querying Guide.Using UPDATE and DELETE Statements - Rounding out the INSERT and SELECTion of data, this section will describe from a Core perspective the use of the
UpdateandDeleteconstructs. ORM-specific UPDATE and DELETE is similarly described in the Data Manipulation with the ORM section.
flambé! the dragon and The Alchemist image designs created and generously donated by Rotem Yaari.
Created using Sphinx 8.2.3. Documentation last generated: Tue 21 Oct 2025 06:01:18 PM EDT