SQLAlchemy
Introduction
These docs written for sqlalchemy == 2.0
- 🏠 SQLAlchemy Home
- 📖 SQLAlchemy Docs Index
- 📄 SQLAlchemy ORM Quick Start
- Learn the new 2.0 syntax with a guided tutorial/quickstart.
- 📄 SQLAlchemy Unified Tutorial
- The 2.0 release of SQLAlchemy introduced a new ORM syntax. It is different enough from versions prior to 2.0 that a tutorial demonstrating the "old" and "new" ways of doing things was needed.
- The newer 2.0 syntax is simpler and more Pythonic, and feels more flexible (subjective opinions).
- 📄 SQLAlchemy ORM Quick Start
Sample Code
Check the pages in this section for sample code & explanations for using SQLAlchemy in your app.
Note
Check my red-utils
package's .ext.sqlalchemy_utils
module for an example database
module. You can essentially copy/paste the code into a directory in your project like src/app/database/
.
Full sample: From initializing DBSettings to adding an entity
Todo
- Setup
-
Base
creation -
DBSettings
init- (Optional) with
dynaconf
- (Optional) with
-
- Model classes
- With mixin classes/multi-inheritance
- With custom annotated columns
- Get session & repository
- Commit entity