SQLAlchemy 2.1 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
Insert
construct. 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
Select
construct, which is the most commonly used object in SQLAlchemy. TheSelect
construct 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
Update
andDelete
constructs. 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 7.2.6. Documentation last generated: Fri 08 Nov 2024 08:32:22 AM EST