#83: Relationship Patterns in SQLAlchemy ORM
SQLAlchemy ORM offers us the same basic relationship patterns as the Core part. However, with a little bit more code we can create navigation properties that makes working with our objects much simpler.
SQLAlchemy ORM offers us the same basic relationship patterns as the Core part. However, with a little bit more code we can create navigation properties that makes working with our objects much simpler.
When we access our database, we most often only want to work with a few specific rows and not the whole table. Let us look what syntax SQLAlchemy ORM uses to filter our rows.
With the foundation for SQLAlchemy ORM in place, it is now time to do some CRUD operations without writing SQL statements.
The Object Relational Mapper (ORM) part of SQLAlchemy offers us a way to persist data in a database without the need to write our own SQL statements. Let us look how that works and what rules we need to follow.
Relationships between tables are of little use if we cannot join them in our queries. Let's look at how SQLAlchemy Core creates JOIN statements.
Relational databases are great to protect your data integrity. However, that only works when you tell the database which objects have a relationship. Let us look what SQLAlchemy Core offers us to create foreign keys through metadata.
When we access our database, we most often only want to work with a few specific rows and not the whole table. Let us look how we can use filters in SQLAlchemy Core.
One of the benefits of SQLAlchemy is that it comes with an abstraction for SQL. Let’s find out how a bit of metadata can help us write much less database code.
If you know your SQL and want to use it with Python, SQLAlchemy is a good tool to help you. You can start with plain SQL commands and later move to a higher level of abstraction.
The big challenge for me in learning SQLAlchemy was that it comes with a lot of terms and concepts that you need to know before you can start to understand this toolkit. Some are familiar and work the same way as in other programming languages, while others are an additional level of abstraction that were new for me. To clear things up, I wrote this post to explain the meaning of the most important concepts in SQLAlchemy.