SQLAlchemy Guides
SQLAlchemy is one of the most popular ORMs in the Python ecosystem and ships with an excellent migration tool, Alembic. However, in some scenarios listed below, Alembic may not be sufficient. Atlas provides a seamless integration with SQLAlchemy, allowing you to keep defining your schema as SQLAlchemy models while enjoying Atlas' schema management features. Some examples are:
-
Advanced database features: Atlas can recognize and detect changes in many database features that are not natively supported by SQLAlchemy and Alembic, such as:
- Views
- Functions & Procedures
- Triggers
- Sequences
- Row-Level Security
- And much more!
With Composite Schemas, these object can be now managed as part of your code.
-
CI/CD support: Catch issues before they hit production with robust GitHub Actions, GitLab, and CircleCI Orbs integrations. Detect risky migrations, test data migrations, database functions, and more. In addition, Atlas can be integrated into your pipelines to provide native integrations with your deployment machinery (e.g. Kubernetes Operator, Terraform, etc.).
-
Declarative workflow: Atlas can be used to manage your schema as code - the schema is continuously synced to Atlas Cloud and Atlas generates a migration plan for every new change, removing the need for a migration directory.
Quick Start
Get started with Atlas and SQLAlchemy.
Loading SQLAlchemy Models Into Atlas
To use Atlas with SQLAlchemy, there are two modes in which the Atlas SQLAlchemy Provider can load your schema. Choose the one that suits your project setup.Standalone Mode
The common case. If all of your SQLAlchemy models exist in a single module, you can use the provider directly to load your SQLAlchemy schema into Atlas.
Python Script
Use Atlas as a Python script to load and manage your SQLAlchemy schema in Atlas.
Managing Database Objects
Like many ORMs, SQLAlchemy provides a way to define the most common database objects, such as tables, columns, and indexes using Python classes and decorators. Atlas extends this capability by allowing you to define more advanced database objects such as composite types, domain types, and triggers.