📝 Update admonitions in annotations (#1065)

This commit is contained in:
Sebastián Ramírez 2024-08-12 16:38:19 -05:00 committed by GitHub
parent d55af68fd7
commit ee44f3b85e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 71 additions and 32 deletions

View File

@ -307,9 +307,12 @@
33. Print the `hero_1`. 33. Print the `hero_1`.
!!! info /// info
Even if the `hero_1` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute. Even if the `hero_1` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
///
Because the `hero_1` is fresh it has all it's data available. Because the `hero_1` is fresh it has all it's data available.
Generates the output: Generates the output:
@ -320,9 +323,12 @@
34. Print the `hero_2`. 34. Print the `hero_2`.
!!! info /// info
Even if the `hero_2` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute. Even if the `hero_2` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
///
Because the `hero_2` is fresh it has all it's data available. Because the `hero_2` is fresh it has all it's data available.
Generates the output: Generates the output:
@ -333,9 +339,12 @@
35. Print the `hero_3`. 35. Print the `hero_3`.
!!! info /// info
Even if the `hero_3` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute. Even if the `hero_3` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
///
Because the `hero_3` is fresh it has all it's data available. Because the `hero_3` is fresh it has all it's data available.
Generates the output: Generates the output:

View File

@ -14,11 +14,14 @@
3. Get one hero object, expecting exactly one. 3. Get one hero object, expecting exactly one.
!!! tip /// tip
This ensures there's no more than one, and that there's exactly one, not `None`. This ensures there's no more than one, and that there's exactly one, not `None`.
This would never return `None`, instead it would raise an exception. This would never return `None`, instead it would raise an exception.
///
4. Print the hero object. 4. Print the hero object.
This generates the output: This generates the output:

View File

@ -22,5 +22,8 @@
We tell it that with the `poolclass=StaticPool` parameter. We tell it that with the `poolclass=StaticPool` parameter.
!!! info /// info
You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a> You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a>
///

View File

@ -22,5 +22,8 @@
We tell it that with the `poolclass=StaticPool` parameter. We tell it that with the `poolclass=StaticPool` parameter.
!!! info /// info
You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a> You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a>
///

View File

@ -22,5 +22,8 @@
We tell it that with the `poolclass=StaticPool` parameter. We tell it that with the `poolclass=StaticPool` parameter.
!!! info /// info
You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a> You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a>
///

View File

@ -16,11 +16,14 @@
7. Create a new **session** to query data. 7. Create a new **session** to query data.
!!! tip /// tip
Notice that this is a new **session** independent from the one in the other function above. Notice that this is a new **session** independent from the one in the other function above.
But it still uses the same **engine**. We still have one engine for the whole application. But it still uses the same **engine**. We still have one engine for the whole application.
///
8. Use the `select()` function to create a statement selecting all the `Hero` objects. 8. Use the `select()` function to create a statement selecting all the `Hero` objects.
This selects all the rows in the `hero` table. This selects all the rows in the `hero` table.

View File

@ -13,11 +13,14 @@
3. Get one hero object, expecting exactly one. 3. Get one hero object, expecting exactly one.
!!! tip /// tip
This ensures there's no more than one, and that there's exactly one, not `None`. This ensures there's no more than one, and that there's exactly one, not `None`.
This would never return `None`, instead it would raise an exception. This would never return `None`, instead it would raise an exception.
///
4. Print the hero object. 4. Print the hero object.
This generates the output: This generates the output:

View File

@ -35,13 +35,16 @@
INFO Engine [no key 0.00020s] ('Captain North America',) INFO Engine [no key 0.00020s] ('Captain North America',)
``` ```
!!! tip /// tip
See the `BEGIN` at the top? See the `BEGIN` at the top?
This is SQLAlchemy automatically starting a transaction for us. This is SQLAlchemy automatically starting a transaction for us.
This way, we could revert the last changes (if there were some) if we wanted to, even if the SQL to create them was already sent to the database. This way, we could revert the last changes (if there were some) if we wanted to, even if the SQL to create them was already sent to the database.
///
7. Get one hero object for this new query. 7. Get one hero object for this new query.
The only one that should be there for **Captain North America**. The only one that should be there for **Captain North America**.
@ -98,11 +101,14 @@
INFO Engine COMMIT INFO Engine COMMIT
``` ```
!!! tip /// tip
See how SQLAlchemy (that powers SQLModel) optimizes the SQL to do as much work as possible in a single batch. See how SQLAlchemy (that powers SQLModel) optimizes the SQL to do as much work as possible in a single batch.
Here it updates both heroes in a single SQL query. Here it updates both heroes in a single SQL query.
///
16. Refresh the first hero. 16. Refresh the first hero.
This generates the output: This generates the output:
@ -115,9 +121,12 @@
INFO Engine [generated in 0.00023s] (2,) INFO Engine [generated in 0.00023s] (2,)
``` ```
!!! tip /// tip
Because we just committed a SQL transaction with `COMMIT`, SQLAlchemy will automatically start a new transaction with `BEGIN`. Because we just committed a SQL transaction with `COMMIT`, SQLAlchemy will automatically start a new transaction with `BEGIN`.
///
17. Refresh the second hero. 17. Refresh the second hero.
This generates the output: This generates the output:
@ -129,9 +138,12 @@
INFO Engine [cached since 0.001709s ago] (7,) INFO Engine [cached since 0.001709s ago] (7,)
``` ```
!!! tip /// tip
SQLAlchemy is still using the previous transaction, so it doesn't have to create a new one. SQLAlchemy is still using the previous transaction, so it doesn't have to create a new one.
///
18. Print the first hero, now updated. 18. Print the first hero, now updated.
This generates the output: This generates the output: