mirror of
https://github.com/fastapi/sqlmodel.git
synced 2026-03-13 09:29:54 +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
@@ -70,8 +70,11 @@ You can try that SQL statement in **DB Explorer for SQLite**.
|
||||
|
||||
Make sure to open the same database we already created by clicking <kbd>Open Database</kbd> and selecting the same `database.db` file.
|
||||
|
||||
!!! tip
|
||||
If you don't have that `database.db` file with the table `hero`, you can re-create it by running the Python program at the top. 👆
|
||||
/// tip
|
||||
|
||||
If you don't have that `database.db` file with the table `hero`, you can re-create it by running the Python program at the top. 👆
|
||||
|
||||
///
|
||||
|
||||
Then go to the <kbd>Execute SQL</kbd> tab and copy the SQL from above.
|
||||
|
||||
@@ -141,10 +144,13 @@ We'll create 3 right away, for the 3 heroes:
|
||||
|
||||
</details>
|
||||
|
||||
!!! tip
|
||||
The code above in this file (the omitted code) is just the same code that you see at the top of this chapter.
|
||||
/// tip
|
||||
|
||||
The same code we used before to create the `Hero` model.
|
||||
The code above in this file (the omitted code) is just the same code that you see at the top of this chapter.
|
||||
|
||||
The same code we used before to create the `Hero` model.
|
||||
|
||||
///
|
||||
|
||||
We are putting that in a function `create_heroes()`, to call it later once we finish it.
|
||||
|
||||
@@ -204,8 +210,11 @@ Then we can create a new session:
|
||||
|
||||
The new `Session` takes an `engine` as a parameter. And it will use the **engine** underneath.
|
||||
|
||||
!!! tip
|
||||
We will see a better way to create a **session** using a `with` block later.
|
||||
/// tip
|
||||
|
||||
We will see a better way to create a **session** using a `with` block later.
|
||||
|
||||
///
|
||||
|
||||
## Add Model Instances to the Session
|
||||
|
||||
@@ -237,10 +246,13 @@ And once we are ready, we can **commit** those changes, and then the **session**
|
||||
|
||||
This makes the interactions with the database more efficient (plus some extra benefits).
|
||||
|
||||
!!! info "Technical Details"
|
||||
The session will create a new transaction and execute all the SQL code in that transaction.
|
||||
/// info | Technical Details
|
||||
|
||||
This ensures that the data is saved in a single batch, and that it will all succeed or all fail, but it won't leave the database in a broken state.
|
||||
The session will create a new transaction and execute all the SQL code in that transaction.
|
||||
|
||||
This ensures that the data is saved in a single batch, and that it will all succeed or all fail, but it won't leave the database in a broken state.
|
||||
|
||||
///
|
||||
|
||||
## Commit the Session Changes
|
||||
|
||||
@@ -433,8 +445,11 @@ Let's focus on the new code:
|
||||
|
||||
{!./docs_src/tutorial/insert/annotations/en/tutorial003.md!}
|
||||
|
||||
!!! tip
|
||||
Review what each line does by clicking each number bubble in the code. 👆
|
||||
/// tip
|
||||
|
||||
Review what each line does by clicking each number bubble in the code. 👆
|
||||
|
||||
///
|
||||
|
||||
You can now put it in a `app.py` file and run it with Python. And you will see an output like the one shown above.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user