- Use an external library to simplify tasks from earlier ORM lessons.
- Manage database tables and schemas without ever writing SQL through Alembic.
- Use SQLAlchemy to create, read, update and delete records in a SQL database.
- Schema: the blueprint of a database. Describes how data relates to other data in tables, columns, and relationships between them.
- Persist: save a schema in a database.
- Engine: a Python object that translates SQL to Python and vice-versa.
- Session: a Python object that uses an engine to allow us to programmatically interact with a database.
- Transaction: a strategy for executing database statements such that the group succeeds or fails as a unit.
- Migration: the process of moving data from one or more databases to one or more target databases.
In our previous module, we learned about ORMs. Using sqlite3
and concepts
in object-oriented programming in Python, we built tools to map Python classes
to database tables and vice-versa. This is a useful skill for your future work,
but it has some distinct limitations:
- It only works with one type of SQL database,
sqlite3
. - It only covers the functionality that we needed for our
Dog
andSong
classes. - We won't know how other groups' ORMs work.
- Others won't know how our ORM works.
In order to address these concerns, several groups of programmers began development on ORMs that had a broad range of compatibilites and functionality, robust documentation, and regular maintenance to keep up with evolving programming languages.
In our curriculum, we will be working with SQLAlchemy, a popular Python ORM. There are several other popular Python ORMS- most notably the Django ORM- but SQLAlchemy provides us the most functionality without too much that we don't need. It is used by many big tech companies like Yelp!, reddit, and DropBox.
That being said, SQLAlchemy is a very powerful library, and we will only cover a small fraction of its capabilities in this curriculum. There are many fantastic resources available to you for free online or through Flatiron that will allow you to continue to learn all about SQLAlchemy as you proceed through your career.