From 4542086290412eb54ebd37defa3d8890b9eb5163 Mon Sep 17 00:00:00 2001 From: Alissa Date: Sun, 27 Oct 2024 17:55:49 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Update=20includes=20for=20`docs/?= =?UTF-8?q?tutorial/connect/create-connected-rows.md`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tutorial/connect/create-connected-rows.md | 240 +----------------- 1 file changed, 6 insertions(+), 234 deletions(-) diff --git a/docs/tutorial/connect/create-connected-rows.md b/docs/tutorial/connect/create-connected-rows.md index d72c0b2247..a694c94fc3 100644 --- a/docs/tutorial/connect/create-connected-rows.md +++ b/docs/tutorial/connect/create-connected-rows.md @@ -45,25 +45,7 @@ We will later update **Spider-Boy** to add him to the **Preventers** team too, b We will continue with the code in the previous example and we will add more things to it. -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/create_tables/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/create_tables/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/create_tables/tutorial001_py310.py *} Make sure you remove the `database.db` file before running the examples to get the same results. @@ -75,49 +57,7 @@ And now we will also create the teams there. 🎉 Let's start by creating two teams: -//// tab | Python 3.10+ - -```Python hl_lines="3-9" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py[ln:29-35]!} - -# Code below omitted 👇 -``` - -//// - -//// tab | Python 3.7+ - -```Python hl_lines="3-9" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-37]!} - -# Code below omitted 👇 -``` - -//// - -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[29:35] hl[3:9] *} This would hopefully look already familiar. @@ -133,49 +73,7 @@ And finally we **commit** the session to save the changes to the database. Let's not forget to add this function `create_heroes()` to the `main()` function so that we run it when calling the program from the command line: -//// tab | Python 3.10+ - -```Python hl_lines="5" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py[ln:61-63]!} - -# Code below omitted 👇 -``` - -//// - -//// tab | Python 3.7+ - -```Python hl_lines="5" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:63-65]!} - -# Code below omitted 👇 -``` - -//// - -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[61:63] hl[5] *} ## Run it @@ -208,49 +106,7 @@ Now let's create one hero object to start. As the `Hero` class model now has a field (column, attribute) `team_id`, we can set it by using the ID field from the `Team` objects we just created before: -//// tab | Python 3.10+ - -```Python hl_lines="12" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py[ln:29-39]!} - -# Code below omitted 👇 -``` - -//// - -//// tab | Python 3.7+ - -```Python hl_lines="12" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-41]!} - -# Code below omitted 👇 -``` - -//// - -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[29:39] hl[12] *} We haven't committed this hero to the database yet, but there are already a couple of things to pay **attention** to. @@ -274,49 +130,7 @@ INFO Engine [generated in 0.00025s] (2,) Let's now create two more heroes: -//// tab | Python 3.10+ - -```Python hl_lines="14-20" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py[ln:29-50]!} - -# Code below omitted 👇 -``` - -//// - -//// tab | Python 3.7+ - -```Python hl_lines="14-20" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-52]!} - -# Code below omitted 👇 -``` - -//// - -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[29:50] hl[14:20] *} When creating `hero_rusty_man`, we are accessing `team_preventers.id`, so that will also trigger a refresh of its data, generating an output of: @@ -347,49 +161,7 @@ INFO Engine COMMIT Now let's refresh and print those new heroes to see their new ID pointing to their teams: -//// tab | Python 3.10+ - -```Python hl_lines="26-28 30-32" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py[ln:29-58]!} - -# Code below omitted 👇 -``` - -//// - -//// tab | Python 3.7+ - -```Python hl_lines="26-28 30-32" -# Code above omitted 👆 - -{!./docs_src/tutorial/connect/insert/tutorial001.py[ln:31-60]!} - -# Code below omitted 👇 -``` - -//// - -/// details | 👀 Full file preview - -//// tab | Python 3.10+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!} -``` - -//// - -//// tab | Python 3.7+ - -```Python -{!./docs_src/tutorial/connect/insert/tutorial001.py!} -``` - -//// - -/// +{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[29:58] hl[26:28,30:32] *} If we execute that in the command line, it will output: