CRUD Operations
All database operations are performed using a Session.Create a Session
File: database.py
File: main.py
Create (Insert)
File: main.py
Explanation
Student object.
Read (Select)
File: main.py
Explanation
Result object.
Student objects and returns them as a Python list.
Update
File: main.py
Explanation
1.
Alternative (Direct Query)
Delete
File: main.py
Explanation
Alternative (Direct Query)
Rollback Changes
File: main.py
Explanation
Close the Session
File: main.py
Explanation
Quick Revision
Note: The object-based approach is the recommended way to work with SQLAlchemy ORM. Directupdate()anddelete()statements are useful for bulk operations and will be covered in detail in the Advanced Queries chapter.