✏ Fix multiple typos and some rewording (#22)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
6615b111d9
commit
2013c69c4d
@ -85,7 +85,7 @@ Some examples of databases that work like this could be **PostgreSQL**, **MySQL*
|
||||
|
||||
### Distributed servers
|
||||
|
||||
In some cases, the database could even be a group server applications running on different machines, working together and communicating between them to be more efficient and handle more data.
|
||||
In some cases, the database could even be a group of server applications running on different machines, working together and communicating between them to be more efficient and handle more data.
|
||||
|
||||
In this case, your code would talk to one or more of these server applications running on different machines.
|
||||
|
||||
|
@ -107,7 +107,7 @@ Most of that should look familiar:
|
||||
|
||||
The column will be named `team_id`. It will be an integer, and it could be `NULL` in the database (or `None` in Python), becase there could be some heroes that don't belong to any team.
|
||||
|
||||
As we don't have to explicitly pass `team_id=None` when creating a hero, we add a default of `None` to the `Field()`.
|
||||
We add a default of `None` to the `Field()` so we don't have to explicitly pass `team_id=None` when creating a hero.
|
||||
|
||||
Now, here's the new part:
|
||||
|
||||
|
@ -81,7 +81,7 @@ In this case, instead of getting all the 7 rows, we are limiting them to only ge
|
||||
|
||||
<img class="shadow" alt="table with first 3 rows selected" src="/img/tutorial/offset-and-limit/limit.svg">
|
||||
|
||||
## Run the Program on the Comamnd Line
|
||||
## Run the Program on the Command Line
|
||||
|
||||
If we run it on the command line, it will output:
|
||||
|
||||
@ -153,7 +153,7 @@ Each of those methods applies the change in the internal special select statemen
|
||||
|
||||
**Offset** means "skip this many rows", and as we want to skip the ones we already saw, the first three, we use `.offset(3)`.
|
||||
|
||||
## Run the Program with Offset on the Comamnd Line
|
||||
## Run the Program with Offset on the Command Line
|
||||
|
||||
Now we can run the program on the command line, and it will output:
|
||||
|
||||
@ -207,9 +207,9 @@ The database right now has **only 7 rows**, so this query can only get 1 row.
|
||||
|
||||
But don't worry, the database won't throw an error trying to get 3 rows when there's only one (as would happen with a Python list).
|
||||
|
||||
The database knows that we want to **limit** the number of results, but it doesn't necessarily has to find those many results.
|
||||
The database knows that we want to **limit** the number of results, but it doesn't necessarily have to find that many results.
|
||||
|
||||
## Run the Program with the Last Batch on the Comamnd Line
|
||||
## Run the Program with the Last Batch on the Command Line
|
||||
|
||||
And if we run it in the command line, it will output:
|
||||
|
||||
@ -271,7 +271,7 @@ Of course, you can also combine `.limit()` and `.offset()` with `.where()` and o
|
||||
|
||||
</details>
|
||||
|
||||
## Run the Program with Limit and Where on the Comamnd Line
|
||||
## Run the Program with Limit and Where on the Command Line
|
||||
|
||||
If we run it on the command line, it will find all the heroes in the database with an age above 32. That would normally be 4 heroes.
|
||||
|
||||
|
@ -97,9 +97,9 @@ FROM hero
|
||||
|
||||
That would end up in the same result. Although we won't use that for **SQLModel**.
|
||||
|
||||
### `SELECT` Less Columns
|
||||
### `SELECT` Fewer Columns
|
||||
|
||||
We can also `SELECT` less columns, for example:
|
||||
We can also `SELECT` fewer columns, for example:
|
||||
|
||||
```SQL
|
||||
SELECT id, name
|
||||
@ -150,7 +150,7 @@ Another variation is that most of the SQL keywords like `SELECT` can also be wri
|
||||
|
||||
This is the interesting part. The tables returned by SQL databases **don't have to exist** in the database as independent tables. 🧙
|
||||
|
||||
For example, in our database, we only have one table that has all the columns, `id`, `name`, `secret_name`, `age`. And here we are getting a result table with less columns.
|
||||
For example, in our database, we only have one table that has all the columns, `id`, `name`, `secret_name`, `age`. And here we are getting a result table with fewer columns.
|
||||
|
||||
One of the main points of SQL is to be able to keep the data structured in different tables, without repeating data, etc, and then query the database in many ways and get many different tables as a result.
|
||||
|
||||
|
@ -39,7 +39,7 @@ In a similar way to `SELECT` statements, the first part defines the columns to w
|
||||
|
||||
And the second part, with the `WHERE`, defines to which rows it should apply that update.
|
||||
|
||||
In this case, as we only have one hero with the name `"Spider-Boy"`, it will only apply the udpate in that row.
|
||||
In this case, as we only have one hero with the name `"Spider-Boy"`, it will only apply the update in that row.
|
||||
|
||||
!!! info
|
||||
Notice that in the `UPDATE` the single equals sign (`=`) means **assignment**, setting a column to some value.
|
||||
@ -70,7 +70,7 @@ After that update, the data in the table will look like this, with the new age f
|
||||
</table>
|
||||
|
||||
!!! tip
|
||||
It will probably be more common to find the row to update by Id, for example:
|
||||
It will probably be more common to find the row to update by `id`, for example:
|
||||
|
||||
```SQL
|
||||
UPDATE hero
|
||||
@ -340,7 +340,7 @@ Now let's review all that code:
|
||||
|
||||
The update process with **SQLModel** is more or less the same as with creating new objects, you add them to the session, and then commit them.
|
||||
|
||||
This also means that you can update several fields (atributes, columns) at once, and you can also update several objects (heroes) at once:
|
||||
This also means that you can update several fields (attributes, columns) at once, and you can also update several objects (heroes) at once:
|
||||
|
||||
```{ .python .annotate hl_lines="15-17 19-21 23" }
|
||||
# Code above omitted 👆
|
||||
|
@ -271,7 +271,7 @@ In the example above we are using two equal signs (`==`). That's called the "**e
|
||||
!!! tip
|
||||
An **operator** is just a symbol that is put beside one value or in the middle of two values to do something with them.
|
||||
|
||||
`==` is called **equality** operator because it checks if two things are **equal**.
|
||||
`==` is called the **equality** operator because it checks if two things are **equal**.
|
||||
|
||||
When writing Python, if you write something using this equality operator (`==`) like:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user