From e88b5d3691a2b0f939cd301409780c4c2f50d5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 30 Aug 2022 18:35:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Adjust=20and=20clarify=20docs=20?= =?UTF-8?q?for=20`docs/tutorial/create-db-and-table.md`=20(#426)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tutorial/create-db-and-table.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/create-db-and-table.md b/docs/tutorial/create-db-and-table.md index 2bdecaac67..b81d309284 100644 --- a/docs/tutorial/create-db-and-table.md +++ b/docs/tutorial/create-db-and-table.md @@ -498,7 +498,7 @@ In this example it's just the `SQLModel.metadata.create_all(engine)`. Let's put it in a function `create_db_and_tables()`: -```Python hl_lines="22-23" +```Python hl_lines="19-20" {!./docs_src/tutorial/create_db_and_table/tutorial002.py[ln:1-20]!} # More code here later 👇 @@ -513,9 +513,9 @@ Let's put it in a function `create_db_and_tables()`: -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**. +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. -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. +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. Now we would be able to, for example, import the `Hero` class in some other file without having those **side effects**.