Skip to content

Commit e88b5d3

Browse files
authored
📝 Adjust and clarify docs for docs/tutorial/create-db-and-table.md (#426)
1 parent fdb049b commit e88b5d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/tutorial/create-db-and-table.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ In this example it's just the `SQLModel.metadata.create_all(engine)`.
498498

499499
Let's put it in a function `create_db_and_tables()`:
500500

501-
```Python hl_lines="22-23"
501+
```Python hl_lines="19-20"
502502
{!./docs_src/tutorial/create_db_and_table/tutorial002.py[ln:1-20]!}
503503

504504
# More code here later 👇
@@ -513,9 +513,9 @@ Let's put it in a function `create_db_and_tables()`:
513513

514514
</details>
515515

516-
If `SQLModel.metadata.create_all(engine)` was not in a function and we tried to import something from this module (from this file) in another, it would try to create the database and table **every time**.
516+
If `SQLModel.metadata.create_all(engine)` was not in a function and we tried to import something from this module (from this file) in another, it would try to create the database and table **every time** we executed that other file that imported this module.
517517

518-
We don't want that to happen like that, only when we **intend** it to happen, that's why we put it in a function.
518+
We don't want that to happen like that, only when we **intend** it to happen, that's why we put it in a function, because we can make sure that the tables are created only when we call that function, and not when this module is imported somewhere else.
519519

520520
Now we would be able to, for example, import the `Hero` class in some other file without having those **side effects**.
521521

0 commit comments

Comments
 (0)