mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Update Tortoise docs and examples
This commit is contained in:
@@ -32,14 +32,14 @@ As you can see, **FastAPI Users** provides a mixin that will include base fields
|
||||
|
||||
## Create the tables
|
||||
|
||||
We'll now create an SQLAlchemy enigne and ask it to create all the defined tables.
|
||||
We'll now create an SQLAlchemy engine and ask it to create all the defined tables.
|
||||
|
||||
```py hl_lines="36 37 38 39 40"
|
||||
{!./src/db_sqlalchemy.py!}
|
||||
```
|
||||
|
||||
!!!tip
|
||||
In production, you would probably want to create the tables with Alembic, integrated with migrations, etc.
|
||||
!!! warning
|
||||
In production, it's strongly recommended to setup a migration system to update your SQL schemas. See [Alembic](https://alembic.sqlalchemy.org/en/latest/).
|
||||
|
||||
## Create the database adapter
|
||||
|
||||
|
||||
@@ -44,12 +44,15 @@ Notice that we pass a reference to your [`UserDB` model](../model.md).
|
||||
|
||||
For using Tortoise ORM we must register our models and database.
|
||||
|
||||
Tortoise ORM supports integration with Starlette/FastAPI out-of-the-box. It will automatically bind startup and shutdown events.
|
||||
Tortoise ORM supports integration with FastAPI out-of-the-box. It will automatically bind startup and shutdown events.
|
||||
|
||||
```py hl_lines="33"
|
||||
```py hl_lines="33 34 35 36 37 38"
|
||||
{!./src/db_tortoise.py!}
|
||||
```
|
||||
|
||||
!!! warning
|
||||
In production, it's strongly recommended to setup a migration system to update your SQL schemas. See [https://tortoise-orm.readthedocs.io/en/latest/migration.html](https://tortoise-orm.readthedocs.io/en/latest/migration.html).
|
||||
|
||||
## Next steps
|
||||
|
||||
We will now configure an [authentication method](../authentication/index.md).
|
||||
|
||||
Reference in New Issue
Block a user