@@ -45,25 +45,7 @@ We will later update **Spider-Boy** to add him to the **Preventers** team too, b
4545
4646We will continue with the code in the previous example and we will add more things to it.
4747
48- /// details | 👀 Full file preview
49-
50- //// tab | Python 3.10+
51-
52- ``` Python
53- {!./ docs_src/ tutorial/ connect/ create_tables/ tutorial001_py310.py!}
54- ```
55-
56- ////
57-
58- //// tab | Python 3.7+
59-
60- ``` Python
61- {!./ docs_src/ tutorial/ connect/ create_tables/ tutorial001.py!}
62- ```
63-
64- ////
65-
66- ///
48+ {* ./docs_src/tutorial/connect/create_tables/tutorial001_py310.py * }
6749
6850Make sure you remove the ` database.db ` file before running the examples to get the same results.
6951
@@ -75,49 +57,7 @@ And now we will also create the teams there. 🎉
7557
7658Let's start by creating two teams:
7759
78- //// tab | Python 3.10+
79-
80- ``` Python hl_lines="3-9"
81- # Code above omitted 👆
82-
83- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py[ln:29 - 35 ]!}
84-
85- # Code below omitted 👇
86- ```
87-
88- ////
89-
90- //// tab | Python 3.7+
91-
92- ``` Python hl_lines="3-9"
93- # Code above omitted 👆
94-
95- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py[ln:31 - 37 ]!}
96-
97- # Code below omitted 👇
98- ```
99-
100- ////
101-
102- /// details | 👀 Full file preview
103-
104- //// tab | Python 3.10+
105-
106- ``` Python
107- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py!}
108- ```
109-
110- ////
111-
112- //// tab | Python 3.7+
113-
114- ``` Python
115- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py!}
116- ```
117-
118- ////
119-
120- ///
60+ {* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[ 29:35] hl[ 3:9] * }
12161
12262This would hopefully look already familiar.
12363
@@ -133,49 +73,7 @@ And finally we **commit** the session to save the changes to the database.
13373
13474Let'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:
13575
136- //// tab | Python 3.10+
137-
138- ``` Python hl_lines="5"
139- # Code above omitted 👆
140-
141- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py[ln:61 - 63 ]!}
142-
143- # Code below omitted 👇
144- ```
145-
146- ////
147-
148- //// tab | Python 3.7+
149-
150- ``` Python hl_lines="5"
151- # Code above omitted 👆
152-
153- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py[ln:63 - 65 ]!}
154-
155- # Code below omitted 👇
156- ```
157-
158- ////
159-
160- /// details | 👀 Full file preview
161-
162- //// tab | Python 3.10+
163-
164- ``` Python
165- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py!}
166- ```
167-
168- ////
169-
170- //// tab | Python 3.7+
171-
172- ``` Python
173- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py!}
174- ```
175-
176- ////
177-
178- ///
76+ {* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[ 61:63] hl[ 5] * }
17977
18078## Run it
18179
@@ -208,49 +106,7 @@ Now let's create one hero object to start.
208106
209107As 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:
210108
211- //// tab | Python 3.10+
212-
213- ``` Python hl_lines="12"
214- # Code above omitted 👆
215-
216- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py[ln:29 - 39 ]!}
217-
218- # Code below omitted 👇
219- ```
220-
221- ////
222-
223- //// tab | Python 3.7+
224-
225- ``` Python hl_lines="12"
226- # Code above omitted 👆
227-
228- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py[ln:31 - 41 ]!}
229-
230- # Code below omitted 👇
231- ```
232-
233- ////
234-
235- /// details | 👀 Full file preview
236-
237- //// tab | Python 3.10+
238-
239- ``` Python
240- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py!}
241- ```
242-
243- ////
244-
245- //// tab | Python 3.7+
246-
247- ``` Python
248- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py!}
249- ```
250-
251- ////
252-
253- ///
109+ {* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[ 29:39] hl[ 12] * }
254110
255111We haven't committed this hero to the database yet, but there are already a couple of things to pay ** attention** to.
256112
@@ -274,49 +130,7 @@ INFO Engine [generated in 0.00025s] (2,)
274130
275131Let's now create two more heroes:
276132
277- //// tab | Python 3.10+
278-
279- ``` Python hl_lines="14-20"
280- # Code above omitted 👆
281-
282- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py[ln:29 - 50 ]!}
283-
284- # Code below omitted 👇
285- ```
286-
287- ////
288-
289- //// tab | Python 3.7+
290-
291- ``` Python hl_lines="14-20"
292- # Code above omitted 👆
293-
294- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py[ln:31 - 52 ]!}
295-
296- # Code below omitted 👇
297- ```
298-
299- ////
300-
301- /// details | 👀 Full file preview
302-
303- //// tab | Python 3.10+
304-
305- ``` Python
306- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py!}
307- ```
308-
309- ////
310-
311- //// tab | Python 3.7+
312-
313- ``` Python
314- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py!}
315- ```
316-
317- ////
318-
319- ///
133+ {* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[ 29:50] hl[ 14:20] * }
320134
321135When creating ` hero_rusty_man ` , we are accessing ` team_preventers.id ` , so that will also trigger a refresh of its data, generating an output of:
322136
@@ -347,49 +161,7 @@ INFO Engine COMMIT
347161
348162Now let's refresh and print those new heroes to see their new ID pointing to their teams:
349163
350- //// tab | Python 3.10+
351-
352- ``` Python hl_lines="26-28 30-32"
353- # Code above omitted 👆
354-
355- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py[ln:29 - 58 ]!}
356-
357- # Code below omitted 👇
358- ```
359-
360- ////
361-
362- //// tab | Python 3.7+
363-
364- ``` Python hl_lines="26-28 30-32"
365- # Code above omitted 👆
366-
367- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py[ln:31 - 60 ]!}
368-
369- # Code below omitted 👇
370- ```
371-
372- ////
373-
374- /// details | 👀 Full file preview
375-
376- //// tab | Python 3.10+
377-
378- ``` Python
379- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001_py310.py!}
380- ```
381-
382- ////
383-
384- //// tab | Python 3.7+
385-
386- ``` Python
387- {!./ docs_src/ tutorial/ connect/ insert/ tutorial001.py!}
388- ```
389-
390- ////
391-
392- ///
164+ {* ./docs_src/tutorial/connect/insert/tutorial001_py310.py ln[ 29:58] hl[ 26:28,30:32] * }
393165
394166If we execute that in the command line, it will output:
395167
0 commit comments