SQLAlchemy 1.4 / 2.0 Tutorial
This page is part of the SQLAlchemy 1.4 / 2.0 Tutorial.
Previous: Working with Database Metadata | Next: Inserting Rows with Core
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:
Inserting Rows with Core - 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.
Selecting Rows with Core or ORM - this section will describe in detail
the Select
construct, which is the most commonly used object
in SQLAlchemy. The Select
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.
Updating and Deleting Rows with Core - Rounding out the INSERT and SELECTion
of data, this section will describe from a Core perspective the use of the
Update
and Delete
constructs. ORM-specific
UPDATE and DELETE is similarly described in the
Data Manipulation with the ORM section.
SQLAlchemy 1.4 / 2.0 Tutorial
Next Tutorial Section: Inserting Rows with Core
flambé! the dragon and The Alchemist image designs created and generously donated by Rotem Yaari.
Created using Sphinx 3.5.4.