Fix SQL database tutorial line references and lifespan text
Update the markdown anchors and line/highlight ranges in sql-databases.md to match the current tutorial001 and tutorial002 source files. Also replace the outdated startup event wording with lifespan to reflect the new FastAPI implementation.
Using `check_same_thread=False` allows FastAPI to use the same SQLite database in different threads. This is necessary as **one single request** could use **more than one thread** (for example in dependencies).
@ -87,7 +87,7 @@ Don't worry, with the way the code is structured, we'll make sure we use **a sin
We then add a function that uses `SQLModel.metadata.create_all(engine)` to **create the tables** for all the *table models*.
Here we use the `SessionDep` dependency (a `Session`) to add the new `Hero` to the `Session` instance, commit the changes to the database, refresh the data in the `hero`, and then return it.
@ -131,19 +131,19 @@ Here we use the `SessionDep` dependency (a `Session`) to add the new `Hero` to t
We can **read**`Hero`s from the database using a `select()`. We can include a `limit` and `offset` to paginate the results.
### Create with `HeroCreate` and return a `HeroPublic` { #create-with-herocreate-and-return-a-heropublic }
@ -288,7 +288,7 @@ This new *table model* `Hero` will have the fields sent by the client, and will
Then we return the same *table model*`Hero` as is from the function. But as we declare the `response_model` with the `HeroPublic`*data model*, **FastAPI** will use `HeroPublic` to validate and serialize the data.
@ -304,13 +304,13 @@ By declaring it in `response_model` we are telling **FastAPI** to do its thing,
We can do the same as before to **read**`Hero`s, again, we use `response_model=list[HeroPublic]` to ensure that the data is validated and serialized correctly.