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).
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*.
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.
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 +133,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.
We can **read**`Hero`s from the database using a `select()`. We can include a `limit` and `offset` to paginate the results.