mirror of
https://github.com/fastapi/sqlmodel.git
synced 2025-11-03 05:41:42 +08:00
🔧 Update config with new pymdown extensions (#712)
* 🔧 Update config with new pymdown extensions * 📝 Update admonition blocks syntax * 📝 Update syntax for tabs with new pymdown extensions
This commit is contained in:
committed by
GitHub
parent
71baff6015
commit
a95bd3873d
@ -62,10 +62,13 @@ But here we will make sure we don't share the same **session** in more than one
|
||||
|
||||
And we also need to disable it because in **FastAPI** each request could be handled by multiple interacting threads.
|
||||
|
||||
!!! info
|
||||
That's enough information for now, you can read more about it in the <a href="https://fastapi.tiangolo.com/async/" class="external-link" target="_blank">FastAPI docs for `async` and `await`</a>.
|
||||
/// info
|
||||
|
||||
The main point is, by ensuring you **don't share** the same **session** with more than one request, the code is already safe.
|
||||
That's enough information for now, you can read more about it in the <a href="https://fastapi.tiangolo.com/async/" class="external-link" target="_blank">FastAPI docs for `async` and `await`</a>.
|
||||
|
||||
The main point is, by ensuring you **don't share** the same **session** with more than one request, the code is already safe.
|
||||
|
||||
///
|
||||
|
||||
## **FastAPI** App
|
||||
|
||||
@ -119,8 +122,11 @@ This should be called only once at startup, not before every request, so we put
|
||||
|
||||
## Create Heroes *Path Operation*
|
||||
|
||||
!!! info
|
||||
If you need a refresher on what a **Path Operation** is (an endpoint with a specific HTTP Operation) and how to work with it in FastAPI, check out the <a href="https://fastapi.tiangolo.com/tutorial/first-steps/" class="external-link" target="_blank">FastAPI First Steps docs</a>.
|
||||
/// info
|
||||
|
||||
If you need a refresher on what a **Path Operation** is (an endpoint with a specific HTTP Operation) and how to work with it in FastAPI, check out the <a href="https://fastapi.tiangolo.com/tutorial/first-steps/" class="external-link" target="_blank">FastAPI First Steps docs</a>.
|
||||
|
||||
///
|
||||
|
||||
Let's create the **path operation** code to create a new hero.
|
||||
|
||||
@ -143,12 +149,15 @@ It will be called when a user sends a request with a `POST` **operation** to the
|
||||
|
||||
</details>
|
||||
|
||||
!!! info
|
||||
If you need a refresher on some of those concepts, checkout the FastAPI documentation:
|
||||
/// info
|
||||
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/first-steps/" class="external-link" target="_blank">First Steps</a>
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/path-params/" class="external-link" target="_blank">Path Parameters - Data Validation and Data Conversion</a>
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/body/" class="external-link" target="_blank">Request Body</a>
|
||||
If you need a refresher on some of those concepts, checkout the FastAPI documentation:
|
||||
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/first-steps/" class="external-link" target="_blank">First Steps</a>
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/path-params/" class="external-link" target="_blank">Path Parameters - Data Validation and Data Conversion</a>
|
||||
* <a href="https://fastapi.tiangolo.com/tutorial/body/" class="external-link" target="_blank">Request Body</a>
|
||||
|
||||
///
|
||||
|
||||
## The **SQLModel** Advantage
|
||||
|
||||
@ -162,8 +171,11 @@ And then, because this same **SQLModel** object is not only a **Pydantic** model
|
||||
|
||||
So we can use intuitive standard Python **type annotations**, and we don't have to duplicate a lot of the code for the database models and the API data models. 🎉
|
||||
|
||||
!!! tip
|
||||
We will improve this further later, but for now, it already shows the power of having **SQLModel** classes be both **SQLAlchemy** models and **Pydantic** models at the same time.
|
||||
/// tip
|
||||
|
||||
We will improve this further later, but for now, it already shows the power of having **SQLModel** classes be both **SQLAlchemy** models and **Pydantic** models at the same time.
|
||||
|
||||
///
|
||||
|
||||
## Read Heroes *Path Operation*
|
||||
|
||||
@ -226,11 +238,14 @@ $ uvicorn main:app
|
||||
|
||||
</div>
|
||||
|
||||
!!! info
|
||||
The command `uvicorn main:app` refers to:
|
||||
/// info
|
||||
|
||||
* `main`: the file `main.py` (the Python "module").
|
||||
* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
|
||||
The command `uvicorn main:app` refers to:
|
||||
|
||||
* `main`: the file `main.py` (the Python "module").
|
||||
* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
|
||||
|
||||
///
|
||||
|
||||
### Uvicorn `--reload`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user