]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
➖ Drop support for Python 3.8 in CI and docs (#1695)
authorSebastián Ramírez <tiangolo@gmail.com>
Fri, 26 Dec 2025 11:03:06 +0000 (03:03 -0800)
committerGitHub <noreply@github.com>
Fri, 26 Dec 2025 11:03:06 +0000 (12:03 +0100)
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
207 files changed:
.github/workflows/test.yml
docs/management-tasks.md
docs/tutorial/automatic-id-none-refresh.md
docs/tutorial/code-structure.md
docs/tutorial/create-db-and-table.md
docs/tutorial/delete.md
docs/tutorial/fastapi/tests.md
docs/tutorial/insert.md
docs/tutorial/select.md
docs/tutorial/update.md
docs_src/advanced/decimal/tutorial001_py39.py [moved from docs_src/advanced/decimal/tutorial001.py with 100% similarity]
docs_src/advanced/uuid/tutorial001_py39.py [moved from docs_src/advanced/uuid/tutorial001.py with 100% similarity]
docs_src/advanced/uuid/tutorial002_py39.py [moved from docs_src/advanced/uuid/tutorial002.py with 100% similarity]
docs_src/tutorial/automatic_id_none_refresh/tutorial001_py39.py [moved from docs_src/tutorial/automatic_id_none_refresh/tutorial001.py with 100% similarity]
docs_src/tutorial/automatic_id_none_refresh/tutorial002_py39.py [moved from docs_src/tutorial/automatic_id_none_refresh/tutorial002.py with 100% similarity]
docs_src/tutorial/code_structure/tutorial001/__init__.py [deleted file]
docs_src/tutorial/code_structure/tutorial001/app.py [deleted file]
docs_src/tutorial/code_structure/tutorial001/database.py [deleted file]
docs_src/tutorial/code_structure/tutorial001/models.py [deleted file]
docs_src/tutorial/code_structure/tutorial002/__init__.py [deleted file]
docs_src/tutorial/code_structure/tutorial002/app.py [deleted file]
docs_src/tutorial/code_structure/tutorial002/database.py [deleted file]
docs_src/tutorial/code_structure/tutorial002/hero_model.py [deleted file]
docs_src/tutorial/code_structure/tutorial002/team_model.py [deleted file]
docs_src/tutorial/connect/create_tables/tutorial001_py39.py [moved from docs_src/tutorial/connect/create_tables/tutorial001.py with 100% similarity]
docs_src/tutorial/connect/delete/tutorial001_py39.py [moved from docs_src/tutorial/connect/delete/tutorial001.py with 100% similarity]
docs_src/tutorial/connect/insert/tutorial001_py39.py [moved from docs_src/tutorial/connect/insert/tutorial001.py with 100% similarity]
docs_src/tutorial/connect/select/tutorial001_py39.py [moved from docs_src/tutorial/connect/select/tutorial001.py with 100% similarity]
docs_src/tutorial/connect/select/tutorial002_py39.py [moved from docs_src/tutorial/connect/select/tutorial002.py with 100% similarity]
docs_src/tutorial/connect/select/tutorial003_py39.py [moved from docs_src/tutorial/connect/select/tutorial003.py with 100% similarity]
docs_src/tutorial/connect/select/tutorial004_py39.py [moved from docs_src/tutorial/connect/select/tutorial004.py with 100% similarity]
docs_src/tutorial/connect/select/tutorial005_py39.py [moved from docs_src/tutorial/connect/select/tutorial005.py with 100% similarity]
docs_src/tutorial/connect/update/tutorial001_py39.py [moved from docs_src/tutorial/connect/update/tutorial001.py with 100% similarity]
docs_src/tutorial/create_db_and_table/annotations/en/tutorial003.md
docs_src/tutorial/create_db_and_table/tutorial001_py39.py [moved from docs_src/tutorial/create_db_and_table/tutorial001.py with 100% similarity]
docs_src/tutorial/create_db_and_table/tutorial002_py39.py [moved from docs_src/tutorial/create_db_and_table/tutorial002.py with 100% similarity]
docs_src/tutorial/create_db_and_table/tutorial003_py39.py [moved from docs_src/tutorial/create_db_and_table/tutorial003.py with 100% similarity]
docs_src/tutorial/delete/tutorial001_py39.py [moved from docs_src/tutorial/delete/tutorial001.py with 100% similarity]
docs_src/tutorial/delete/tutorial002_py39.py [moved from docs_src/tutorial/delete/tutorial002.py with 100% similarity]
docs_src/tutorial/fastapi/app_testing/tutorial001/__init__.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_001.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_002.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_003.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_004.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_005.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_006.md [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/main.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_extra_coverage.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py [deleted file]
docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py [deleted file]
docs_src/tutorial/fastapi/delete/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/limit_and_offset/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/multiple_models/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/multiple_models/tutorial002.py [deleted file]
docs_src/tutorial/fastapi/read_one/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/relationships/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/response_model/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py39.py [moved from docs_src/tutorial/fastapi/simple_hero_api/tutorial001.py with 100% similarity]
docs_src/tutorial/fastapi/teams/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/update/tutorial001.py [deleted file]
docs_src/tutorial/fastapi/update/tutorial002.py [deleted file]
docs_src/tutorial/indexes/tutorial001_py39.py [moved from docs_src/tutorial/indexes/tutorial001.py with 100% similarity]
docs_src/tutorial/indexes/tutorial002_py39.py [moved from docs_src/tutorial/indexes/tutorial002.py with 100% similarity]
docs_src/tutorial/insert/tutorial001_py39.py [moved from docs_src/tutorial/insert/tutorial001.py with 100% similarity]
docs_src/tutorial/insert/tutorial002_py39.py [moved from docs_src/tutorial/insert/tutorial002.py with 100% similarity]
docs_src/tutorial/insert/tutorial003_py39.py [moved from docs_src/tutorial/insert/tutorial003.py with 100% similarity]
docs_src/tutorial/many_to_many/tutorial001.py [deleted file]
docs_src/tutorial/many_to_many/tutorial002.py [deleted file]
docs_src/tutorial/many_to_many/tutorial003.py [deleted file]
docs_src/tutorial/offset_and_limit/tutorial001_py39.py [moved from docs_src/tutorial/offset_and_limit/tutorial001.py with 100% similarity]
docs_src/tutorial/offset_and_limit/tutorial002_py39.py [moved from docs_src/tutorial/offset_and_limit/tutorial002.py with 100% similarity]
docs_src/tutorial/offset_and_limit/tutorial003_py39.py [moved from docs_src/tutorial/offset_and_limit/tutorial003.py with 100% similarity]
docs_src/tutorial/offset_and_limit/tutorial004_py39.py [moved from docs_src/tutorial/offset_and_limit/tutorial004.py with 100% similarity]
docs_src/tutorial/one/tutorial001_py39.py [moved from docs_src/tutorial/one/tutorial001.py with 100% similarity]
docs_src/tutorial/one/tutorial002_py39.py [moved from docs_src/tutorial/one/tutorial002.py with 100% similarity]
docs_src/tutorial/one/tutorial003_py39.py [moved from docs_src/tutorial/one/tutorial003.py with 100% similarity]
docs_src/tutorial/one/tutorial004_py39.py [moved from docs_src/tutorial/one/tutorial004.py with 100% similarity]
docs_src/tutorial/one/tutorial005_py39.py [moved from docs_src/tutorial/one/tutorial005.py with 100% similarity]
docs_src/tutorial/one/tutorial006_py39.py [moved from docs_src/tutorial/one/tutorial006.py with 100% similarity]
docs_src/tutorial/one/tutorial007_py39.py [moved from docs_src/tutorial/one/tutorial007.py with 100% similarity]
docs_src/tutorial/one/tutorial008_py39.py [moved from docs_src/tutorial/one/tutorial008.py with 100% similarity]
docs_src/tutorial/one/tutorial009_py39.py [moved from docs_src/tutorial/one/tutorial009.py with 100% similarity]
docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py [deleted file]
docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py [deleted file]
docs_src/tutorial/relationship_attributes/back_populates/tutorial003.py [deleted file]
docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial001.py [deleted file]
docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial002.py [deleted file]
docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial003.py [deleted file]
docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial004.py [deleted file]
docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial005.py [deleted file]
docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py [deleted file]
docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py [deleted file]
docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py [deleted file]
docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py [deleted file]
docs_src/tutorial/select/tutorial001_py39.py [moved from docs_src/tutorial/select/tutorial001.py with 100% similarity]
docs_src/tutorial/select/tutorial002_py39.py [moved from docs_src/tutorial/select/tutorial002.py with 100% similarity]
docs_src/tutorial/select/tutorial003_py39.py [moved from docs_src/tutorial/select/tutorial003.py with 100% similarity]
docs_src/tutorial/select/tutorial004_py39.py [moved from docs_src/tutorial/select/tutorial004.py with 100% similarity]
docs_src/tutorial/update/tutorial001_py39.py [moved from docs_src/tutorial/update/tutorial001.py with 100% similarity]
docs_src/tutorial/update/tutorial002_py39.py [moved from docs_src/tutorial/update/tutorial002.py with 100% similarity]
docs_src/tutorial/update/tutorial003_py39.py [moved from docs_src/tutorial/update/tutorial003.py with 100% similarity]
docs_src/tutorial/update/tutorial004_py39.py [moved from docs_src/tutorial/update/tutorial004.py with 100% similarity]
docs_src/tutorial/where/tutorial001_py39.py [moved from docs_src/tutorial/where/tutorial001.py with 100% similarity]
docs_src/tutorial/where/tutorial002_py39.py [moved from docs_src/tutorial/where/tutorial002.py with 100% similarity]
docs_src/tutorial/where/tutorial003_py39.py [moved from docs_src/tutorial/where/tutorial003.py with 100% similarity]
docs_src/tutorial/where/tutorial004_py39.py [moved from docs_src/tutorial/where/tutorial004.py with 100% similarity]
docs_src/tutorial/where/tutorial005_py39.py [moved from docs_src/tutorial/where/tutorial005.py with 100% similarity]
docs_src/tutorial/where/tutorial006_py39.py [moved from docs_src/tutorial/where/tutorial006.py with 100% similarity]
docs_src/tutorial/where/tutorial007_py39.py [moved from docs_src/tutorial/where/tutorial007.py with 100% similarity]
docs_src/tutorial/where/tutorial008_py39.py [moved from docs_src/tutorial/where/tutorial008.py with 100% similarity]
docs_src/tutorial/where/tutorial009_py39.py [moved from docs_src/tutorial/where/tutorial009.py with 100% similarity]
docs_src/tutorial/where/tutorial010_py39.py [moved from docs_src/tutorial/where/tutorial010.py with 100% similarity]
docs_src/tutorial/where/tutorial011_py39.py [moved from docs_src/tutorial/where/tutorial011.py with 100% similarity]
requirements-tests.txt
tests/conftest.py
tests/test_advanced/test_decimal/test_tutorial001.py
tests/test_advanced/test_uuid/test_tutorial001.py
tests/test_advanced/test_uuid/test_tutorial002.py
tests/test_select_gen.py
tests/test_tutorial/test_automatic_id_none_refresh/test_tutorial001_tutorial002.py
tests/test_tutorial/test_code_structure/test_tutorial001.py
tests/test_tutorial/test_code_structure/test_tutorial002.py
tests/test_tutorial/test_connect/test_create_connected_tables/test_tutorial001.py
tests/test_tutorial/test_connect/test_delete/test_tutorial001.py
tests/test_tutorial/test_connect/test_insert/test_tutorial001.py
tests/test_tutorial/test_connect/test_select/test_tutorial001_tutorial002.py
tests/test_tutorial/test_connect/test_select/test_tutorial003.py
tests/test_tutorial/test_connect/test_select/test_tutorial004.py
tests/test_tutorial/test_connect/test_select/test_tutorial005.py
tests/test_tutorial/test_connect/test_update/test_tutorial001.py
tests/test_tutorial/test_create_db_and_table/test_tutorial001.py
tests/test_tutorial/test_create_db_and_table/test_tutorial002.py
tests/test_tutorial/test_create_db_and_table/test_tutorial003.py
tests/test_tutorial/test_delete/test_tutorial001_tutorial002.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests001.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests002.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests003.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests004.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests005.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests006.py
tests/test_tutorial/test_fastapi/test_app_testing/test_tutorial001_tests_main.py
tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py
tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py
tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py
tests/test_tutorial/test_indexes/test_tutorial001.py
tests/test_tutorial/test_indexes/test_tutorial002.py
tests/test_tutorial/test_insert/test_tutorial001.py
tests/test_tutorial/test_insert/test_tutorial002.py
tests/test_tutorial/test_insert/test_tutorial003.py
tests/test_tutorial/test_limit_and_offset/test_tutorial001.py
tests/test_tutorial/test_limit_and_offset/test_tutorial002.py
tests/test_tutorial/test_limit_and_offset/test_tutorial003.py
tests/test_tutorial/test_limit_and_offset/test_tutorial004.py
tests/test_tutorial/test_many_to_many/test_tutorial001.py
tests/test_tutorial/test_many_to_many/test_tutorial002.py
tests/test_tutorial/test_many_to_many/test_tutorial003.py
tests/test_tutorial/test_one/test_tutorial001.py
tests/test_tutorial/test_one/test_tutorial002.py
tests/test_tutorial/test_one/test_tutorial003.py
tests/test_tutorial/test_one/test_tutorial004.py
tests/test_tutorial/test_one/test_tutorial005.py
tests/test_tutorial/test_one/test_tutorial006.py
tests/test_tutorial/test_one/test_tutorial007.py
tests/test_tutorial/test_one/test_tutorial008.py
tests/test_tutorial/test_one/test_tutorial009.py
tests/test_tutorial/test_relationship_attributes/test_back_populates/test_tutorial001.py
tests/test_tutorial/test_relationship_attributes/test_back_populates/test_tutorial002.py
tests/test_tutorial/test_relationship_attributes/test_back_populates/test_tutorial003.py
tests/test_tutorial/test_relationship_attributes/test_create_and_update_relationships/test_tutorial001.py
tests/test_tutorial/test_relationship_attributes/test_define_relationship_attributes/test_tutorial001.py
tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial001.py
tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial002.py
tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial003.py
tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial004.py
tests/test_tutorial/test_relationship_attributes/test_delete_records_relationship/test_tutorial005.py
tests/test_tutorial/test_relationship_attributes/test_read_relationships/test_tutorial001.py
tests/test_tutorial/test_relationship_attributes/test_read_relationships/test_tutorial002.py
tests/test_tutorial/test_select/test_tutorial001_tutorial002.py
tests/test_tutorial/test_select/test_tutorial003_tutorial004.py
tests/test_tutorial/test_update/test_tutorial001_tutorial002.py
tests/test_tutorial/test_update/test_tutorial003_tutorial004.py
tests/test_tutorial/test_where/test_tutorial001.py
tests/test_tutorial/test_where/test_tutorial002.py
tests/test_tutorial/test_where/test_tutorial003.py
tests/test_tutorial/test_where/test_tutorial004.py
tests/test_tutorial/test_where/test_tutorial005.py
tests/test_tutorial/test_where/test_tutorial006.py
tests/test_tutorial/test_where/test_tutorial007.py
tests/test_tutorial/test_where/test_tutorial008.py
tests/test_tutorial/test_where/test_tutorial009.py
tests/test_tutorial/test_where/test_tutorial010.py
tests/test_tutorial/test_where/test_tutorial011.py

index 72dff0d732d5f85525d7e7c5189ef2236efe5013..2fea4779a9075b875f9e260ad47d2b6907a063ec 100644 (file)
@@ -30,9 +30,6 @@ jobs:
         pydantic-version:
           - pydantic-v2
         include:
-          - os: macos-latest
-            python-version: "3.8"
-            pydantic-version: pydantic-v1
           - os: windows-latest
             python-version: "3.9"
             pydantic-version: pydantic-v2
index f8deb992f0984c3d73f9189af0a04b2964b6bbca..1ca3765c03caf19ac86b0e83f302bef7b23f9307 100644 (file)
@@ -90,7 +90,7 @@ A PR should have a specific use case that it is solving.
 * If the PR is for a feature, it should have docs.
     * Unless it's a feature we want to discourage, like support for a corner case that we don't want users to use.
 * The docs should include a source example file, not write Python directly in Markdown.
-* If the source example(s) file can have different syntax for Python 3.8, 3.9, 3.10, there should be different versions of the file, and they should be shown in tabs in the docs.
+* If the source example(s) file can have different syntax for different Python versions, there should be different versions of the file, and they should be shown in tabs in the docs.
 * There should be tests testing the source example.
 * Before the PR is applied, the new tests should fail.
 * After applying the PR, the new tests should pass.
index 0e67633dee625bed06a9f3213862301c95b01e8c..93842c6906857c44610aa631a9a2ac11af591ad1 100644 (file)
@@ -342,10 +342,10 @@ And as we created the **engine** with `echo=True`, we can see the SQL statements
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```Python
-{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
+{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002_py39.py!}
 ```
 
 {!./docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md!}
index 6e377b89e4a2228f2ef0db1dfd396ae8b1d1adf8..08a4165429ed7d1c0cc2a94bed7bb1fd4f36de8b 100644 (file)
@@ -67,9 +67,7 @@ We can use these relative imports because, for example, in the file `app.py` (th
 
 You could put all the database Models in a single Python module (a single Python file), for example `models.py`:
 
-```Python
-{!./docs_src/tutorial/code_structure/tutorial001/models.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial001_py310/models.py *}
 
 This way, you wouldn't have to deal with circular imports for other models.
 
@@ -79,9 +77,7 @@ And then you could import the models from this file/module in any other file/mod
 
 Then you could put the code creating the **engine** and the function to create all the tables (if you are not using migrations) in another file `database.py`:
 
-```Python
-{!./docs_src/tutorial/code_structure/tutorial001/database.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial001_py310/database.py *}
 
 This file would also be imported by your application code, to use the shared **engine** and to get and call the function `create_db_and_tables()`.
 
@@ -89,9 +85,7 @@ This file would also be imported by your application code, to use the shared **e
 
 Finally, you could put the code to create the **app** in another file `app.py`:
 
-```Python hl_lines="3-4"
-{!./docs_src/tutorial/code_structure/tutorial001/app.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial001_py310/app.py hl[3:4] *}
 
 Here we import the models, the engine, and the function to create all the tables and then we can use them all internally.
 
@@ -207,9 +201,7 @@ So, we can use it in an `if` block and import things inside the `if` block. And
 
 Using that trick of `TYPE_CHECKING` we can "import" the `Team` in `hero_model.py`:
 
-```Python hl_lines="1  5-6  16"
-{!./docs_src/tutorial/code_structure/tutorial002/hero_model.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial002_py310/hero_model.py hl[1,5:6,16] *}
 
 Have in mind that now we *have* to put the annotation of `Team` as a string: `"Team"`, so that Python doesn't have errors at runtime.
 
@@ -217,9 +209,7 @@ Have in mind that now we *have* to put the annotation of `Team` as a string: `"T
 
 We use the same trick in the `team_model.py` file:
 
-```Python hl_lines="1  5-6  14"
-{!./docs_src/tutorial/code_structure/tutorial002/team_model.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial002_py310/team_model.py hl[1,5:6,14] *}
 
 Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps working. 🎉
 
@@ -227,9 +217,7 @@ Now we get editor support, autocompletion, inline errors, and **SQLModel** keeps
 
 Now, just for completeness, the `app.py` file would import the models from both modules:
 
-```Python hl_lines="4-5  10  12-14"
-{!./docs_src/tutorial/code_structure/tutorial002/app.py!}
-```
+{* ./docs_src/tutorial/code_structure/tutorial002_py310/app.py hl[4:5,10,12:14] *}
 
 And of course, all the tricks with `TYPE_CHECKING` and type annotations in strings are **only needed in the files with circular imports**.
 
index 688567ed4dcf2a4753b054490a2a5a83dd6d2a54..42ec60493257dddd4eb9ba14b60c91b60b87da72 100644 (file)
@@ -562,10 +562,10 @@ Now, let's give the code a final look:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{.python .annotate}
-{!./docs_src/tutorial/create_db_and_table/tutorial003.py!}
+{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py!}
 ```
 
 {!./docs_src/tutorial/create_db_and_table/annotations/en/tutorial003.md!}
index b0eaf6788b3cecadc82e794bdecc719aef38badd..9f494ec44cafd1906861117a8c103b2b7aea5386 100644 (file)
@@ -227,10 +227,10 @@ Now let's review all that code:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{ .python .annotate hl_lines="72-90" }
-{!./docs_src/tutorial/delete/tutorial002.py!}
+{!./docs_src/tutorial/delete/tutorial002_py39.py!}
 ```
 
 {!./docs_src/tutorial/delete/annotations/en/tutorial002.md!}
index ed4f91bcd610c239c21c3e444980fd28d4897bd8..f7fd92c9cb735e376ff2d16f77284134d5393f42 100644 (file)
@@ -14,7 +14,7 @@ We will use the application with the hero models, but without team models, and w
 
 Now we will see how useful it is to have this session dependency. ✨
 
-{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/main.py ln[0] *}
+{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/main.py ln[0] *}
 
 ## File Structure
 
@@ -53,16 +53,16 @@ $ pip install requests pytest
 Let's start with a simple test, with just the basic test code we need the check that the **FastAPI** application is creating a new hero correctly.
 
 ```{ .python .annotate }
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:1-7]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:1-7]!}
         # Some code here omitted, we will see it later 👈
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:20-24]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:20-24]!}
         # Some code here omitted, we will see it later 👈
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py[ln:26-32]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_001.py[ln:26-32]!}
 
 # Code below omitted 👇
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_001.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_001.md!}
 
 /// tip
 
@@ -103,14 +103,14 @@ We will override it to use a different **session** object just for the tests.
 That way we protect the production database and we have better control of the data we are testing.
 
 ```{ .python .annotate hl_lines="4  9-10  12  19" }
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py[ln:1-7]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_002.py[ln:1-7]!}
         # Some code here omitted, we will see it later 👈
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py[ln:15-32]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_002.py[ln:15-32]!}
 
 # Code below omitted 👇
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_002.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_002.md!}
 
 /// tip
 
@@ -131,10 +131,10 @@ sqlite:///testing.db
 So, the testing database will be in the file `testing.db`.
 
 ``` { .python .annotate hl_lines="4  8-11  13  16  33"}
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_003.py!}
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_003.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_003.md!}
 
 ### Import Table Models
 
@@ -187,12 +187,12 @@ Let's update our code to use the in-memory database.
 We just have to change a couple of parameters in the **engine**.
 
 ```{ .python .annotate hl_lines="3  9-13"}
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py[ln:1-13]!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_004.py[ln:1-13]!}
 
 # Code below omitted 👇
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_004.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_004.md!}
 
 /// tip
 
@@ -235,10 +235,10 @@ You can read more about them in the <a href="https://docs.pytest.org/en/6.2.x/fi
 Let's see the first code example with a fixture:
 
 ``` { .python .annotate }
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_005.py!}
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_005.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_005.md!}
 
 /// tip
 
@@ -275,10 +275,10 @@ Each **pytest** fixture (the same way as **FastAPI** dependencies), can require
 So, we can create a **client fixture** that will be used in all the tests, and it will itself require the **session fixture**.
 
 ``` { .python .annotate hl_lines="19-28  31" }
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main_006.py!}
 ```
 
-{!./docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_006.md!}
+{!./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_006.md!}
 
 /// tip
 
@@ -298,7 +298,7 @@ But normally we will create **lots of other test functions**. And now all the bo
 
 Let's add some more tests:
 
-{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[30:58] hl[30,49] *}
+{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[30:58] hl[30,49] *}
 
 /// tip
 
@@ -318,7 +318,7 @@ For these examples, **that would have been simpler**, there's no need to separat
 
 But for the next test function, we will require **both fixtures**, the **client** and the **session**.
 
-{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[1:6,61:81] hl[6,61] *}
+{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[1:6,61:81] hl[6,61] *}
 
 In this test function, we want to check that the *path operation* to **read a list of heroes** actually sends us heroes.
 
@@ -344,7 +344,7 @@ The function for the **client fixture** and the actual testing function will **b
 
 Using the same ideas, requiring the fixtures, creating data that we need for the tests, etc., we can now add the rest of the tests. They look quite similar to what we have done up to now.
 
-{* ./docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py ln[84:125] hl[84,99,114] *}
+{* ./docs_src/tutorial/fastapi/app_testing/tutorial001_py310/test_main.py ln[84:125] hl[84,99,114] *}
 
 ## Run the Tests
 
index c11633d6ce04e485ebecb6e0d5f42316baeaca1b..502a15cb8758bf6953ad1411374ac5c713e47b88 100644 (file)
@@ -39,14 +39,14 @@ This is the code we had to create the database and table, nothing new here:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{.python .annotate hl_lines="22" }
-{!./docs_src/tutorial/create_db_and_table/tutorial003.py[ln:1-20]!}
+{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py[ln:1-20]!}
 
 # More code here later 👈
 
-{!./docs_src/tutorial/create_db_and_table/tutorial003.py[ln:23-24]!}
+{!./docs_src/tutorial/create_db_and_table/tutorial003_py39.py[ln:23-24]!}
 ```
 
 {!./docs_src/tutorial/create_db_and_table/annotations/en/tutorial003.md!}
@@ -343,10 +343,10 @@ Let's focus on the new code:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{.python .annotate }
-{!./docs_src/tutorial/insert/tutorial003.py!}
+{!./docs_src/tutorial/insert/tutorial003_py39.py!}
 ```
 
 {!./docs_src/tutorial/insert/annotations/en/tutorial003.md!}
index cd996932c628ee7347babf46a2bba87083043a5c..3e2037246383f290151027f36022f892754f9055 100644 (file)
@@ -273,10 +273,10 @@ Let's review the code up to this point:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{ .python .annotate }
-{!./docs_src/tutorial/select/tutorial002.py!}
+{!./docs_src/tutorial/select/tutorial002_py39.py!}
 ```
 
 {!./docs_src/tutorial/select/annotations/en/tutorial002.md!}
index 8e60536815cef928dc57f2180b48871d6f41d319..7c7cb5c45d0785427bf99970e7dc29abd7744c02 100644 (file)
@@ -236,10 +236,10 @@ Now let's review all that code:
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{ .python .annotate hl_lines="44-55" }
-{!./docs_src/tutorial/update/tutorial002.py!}
+{!./docs_src/tutorial/update/tutorial002_py39.py!}
 ```
 
 {!./docs_src/tutorial/update/annotations/en/tutorial002.md!}
@@ -272,12 +272,12 @@ This also means that you can update several fields (attributes, columns) at once
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```{ .python .annotate hl_lines="15-17  19-21  23" }
 # Code above omitted 👆
 
-{!./docs_src/tutorial/update/tutorial004.py[ln:44-70]!}
+{!./docs_src/tutorial/update/tutorial004_py39.py[ln:44-70]!}
 
 # Code below omitted 👇
 ```
@@ -296,10 +296,10 @@ This also means that you can update several fields (attributes, columns) at once
 
 ////
 
-//// tab | Python 3.8+
+//// tab | Python 3.9+
 
 ```Python
-{!./docs_src/tutorial/update/tutorial004.py!}
+{!./docs_src/tutorial/update/tutorial004_py39.py!}
 ```
 
 ////
diff --git a/docs_src/tutorial/code_structure/tutorial001/__init__.py b/docs_src/tutorial/code_structure/tutorial001/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/docs_src/tutorial/code_structure/tutorial001/app.py b/docs_src/tutorial/code_structure/tutorial001/app.py
deleted file mode 100644 (file)
index 3d1bfc6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-from sqlmodel import Session
-
-from .database import create_db_and_tables, engine
-from .models import Hero, Team
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        session.add(hero_deadpond)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-
-        print("Created hero:", hero_deadpond)
-        print("Hero's team:", hero_deadpond.team)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/code_structure/tutorial001/database.py b/docs_src/tutorial/code_structure/tutorial001/database.py
deleted file mode 100644 (file)
index d6de16c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-from sqlmodel import SQLModel, create_engine
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
diff --git a/docs_src/tutorial/code_structure/tutorial001/models.py b/docs_src/tutorial/code_structure/tutorial001/models.py
deleted file mode 100644 (file)
index 8e2647b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, SQLModel
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
diff --git a/docs_src/tutorial/code_structure/tutorial002/__init__.py b/docs_src/tutorial/code_structure/tutorial002/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/docs_src/tutorial/code_structure/tutorial002/app.py b/docs_src/tutorial/code_structure/tutorial002/app.py
deleted file mode 100644 (file)
index 2ecaec0..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-from sqlmodel import Session
-
-from .database import create_db_and_tables, engine
-from .hero_model import Hero
-from .team_model import Team
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        session.add(hero_deadpond)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-
-        print("Created hero:", hero_deadpond)
-        print("Hero's team:", hero_deadpond.team)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/code_structure/tutorial002/database.py b/docs_src/tutorial/code_structure/tutorial002/database.py
deleted file mode 100644 (file)
index d6de16c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-from sqlmodel import SQLModel, create_engine
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
diff --git a/docs_src/tutorial/code_structure/tutorial002/hero_model.py b/docs_src/tutorial/code_structure/tutorial002/hero_model.py
deleted file mode 100644 (file)
index 06dd9c6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-from typing import TYPE_CHECKING, Optional
-
-from sqlmodel import Field, Relationship, SQLModel
-
-if TYPE_CHECKING:
-    from .team_model import Team
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional["Team"] = Relationship(back_populates="heroes")
diff --git a/docs_src/tutorial/code_structure/tutorial002/team_model.py b/docs_src/tutorial/code_structure/tutorial002/team_model.py
deleted file mode 100644 (file)
index c8a008b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-from typing import TYPE_CHECKING, List, Optional
-
-from sqlmodel import Field, Relationship, SQLModel
-
-if TYPE_CHECKING:
-    from .hero_model import Hero
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
index f20779a57c5ae0977fb0c3b8417345ca4a9ed214..81b548b50ca55b4fabc73c30d3cfc526185751cc 100644 (file)
@@ -6,7 +6,7 @@
 
 4. Create the `id` field:
 
-    It could be `None` until the database assigns a value to it, so we annotate it with `Optional`.
+    It could be `None` until the database assigns a value to it, so we annotate it with `Optional` (`int | None` in Python 3.10+).
 
     It is a **primary key**, so we use `Field()` and the argument `primary_key=True`.
 
@@ -24,7 +24,7 @@
 
     In the database, the default value will be `NULL`, the SQL equivalent of `None`.
 
-    As this field could be `None` (and `NULL` in the database), we annotate it with `Optional`.
+    As this field could be `None` (and `NULL` in the database), we annotate it with `Optional` (`int | None` in Python 3.10+).
 
 8. Write the name of the database file.
 9. Use the name of the database file to create the database URL.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/__init__.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_001.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_001.md
deleted file mode 100644 (file)
index 936b84b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-1. Import the `app` from the the `main` module.
-
-2. We create a `TestClient` for the FastAPI `app` and put it in the variable `client`.
-
-3. Then we use use this `client` to **talk to the API** and send a `POST` HTTP operation, creating a new hero.
-
-4. Then we get the **JSON data** from the response and put it in the variable `data`.
-
-5. Next we start testing the results with `assert` statements, we check that the status code of the response is `200`.
-
-6. We check that the `name` of the hero created is `"Deadpond"`.
-
-7. We check that the `secret_name` of the hero created is `"Dive Wilson"`.
-
-8. We check that the `age` of the hero created is `None`, because we didn't send an age.
-
-9. We check that the hero created has an `id` created by the database, so it's not `None`.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_002.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_002.md
deleted file mode 100644 (file)
index 0f8555a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-1. Import the `get_session` dependency from the the `main` module.
-
-2. Define the new function that will be the new **dependency override**.
-
-3. This function will return a different **session** than the one that would be returned by the original `get_session` function.
-
-    We haven't seen how this new **session** object is created yet, but the point is that this is a different session than the original one from the app.
-
-    This session is attached to a different **engine**, and that different **engine** uses a different URL, for a database just for testing.
-
-    We haven't defined that new **URL** nor the new **engine** yet, but here we already see the that this object `session` will override the one returned by the original dependency  `get_session()`.
-
-4. Then, the FastAPI `app` object has an attribute `app.dependency_overrides`.
-
-    This attribute is a dictionary, and we can put dependency overrides in it by passing, as the **key**, the **original dependency function**, and as the **value**, the **new overriding dependency function**.
-
-    So, here we are telling the FastAPI app to use `get_session_override` instead of `get_session` in all the places in the code that depend on `get_session`, that is, all the parameters with something like:
-
-    ```Python
-    session: Session = Depends(get_session)
-    ```
-
-5. After we are done with the dependency override, we can restore the application back to normal, by removing all the values in this dictionary `app.dependency_overrides`.
-
-    This way whenever a *path operation function* needs the dependency FastAPI will use the original one instead of the override.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_003.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_003.md
deleted file mode 100644 (file)
index 2b48ebd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-1. Here's a subtle thing to notice.
-
-    Remember that [Order Matters](../create-db-and-table.md#sqlmodel-metadata-order-matters){.internal-link target=_blank} and we need to make sure all the **SQLModel** models are already defined and **imported** before calling `.create_all()`.
-
-    IN this line, by importing something, *anything*, from `.main`, the code in `.main` will be executed, including the definition of the **table models**, and that will automatically register them in `SQLModel.metadata`.
-
-2. Here we create a new **engine**, completely different from the one in `main.py`.
-
-    This is the engine we will use for the tests.
-
-    We use the new URL of the database for tests:
-
-    ```
-    sqlite:///testing.db
-    ```
-
-    And again, we use the connection argument `check_same_thread=False`.
-
-3. Then we call:
-
-    ```Python
-    SQLModel.metadata.create_all(engine)
-    ```
-
-    ...to make sure we create all the tables in the new testing database.
-
-    The **table models** are registered in `SQLModel.metadata` just because we imported *something* from `.main`, and the code in `.main` was executed, creating the classes for the **table models** and automatically registering them in `SQLModel.metadata`.
-
-    So, by the point we call this method, the **table models** are already registered there. 💯
-
-4. Here's where we create the custom **session** object for this test in a `with` block.
-
-    It uses the new custom **engine** we created, so anything that uses this session will be using the testing database.
-
-5. Now, back to the dependency override, it is just returning the same **session** object from outside, that's it, that's the whole trick.
-
-6. By this point, the testing **session** `with` block finishes, and the session is closed, the file is closed, etc.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_004.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_004.md
deleted file mode 100644 (file)
index de754c5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-1. Import `StaticPool` from `sqlmodel`, we will use it in a bit.
-
-2. For the **SQLite URL**, don't write any file name, leave it empty.
-
-    So, instead of:
-
-    ```
-    sqlite:///testing.db
-    ```
-
-    ...just write:
-
-    ```
-    sqlite://
-    ```
-
-    This is enough to tell **SQLModel** (actually SQLAlchemy) that we want to use an **in-memory SQLite database**.
-
-3. Remember that we told the **low-level** library in charge of communicating with SQLite that we want to be able to **access the database from different threads** with `check_same_thread=False`?
-
-    Now that we use an **in-memory database**, we need to also tell SQLAlchemy that we want to be able to use the **same in-memory database** object from different threads.
-
-    We tell it that with the `poolclass=StaticPool` parameter.
-
-    /// info
-
-    You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a>
-
-    ///
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_005.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_005.md
deleted file mode 100644 (file)
index 126e1f1..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-1. Import `pytest`.
-
-2. Use the `@pytest.fixture()` decorator on top of the function to tell pytest that this is a **fixture** function (equivalent to a FastAPI dependency).
-
-    We also give it a name of `"session"`, this will be important in the testing function.
-
-3. Create the fixture function. This is equivalent to a FastAPI dependency function.
-
-    In this fixture we create the custom **engine**, with the in-memory database, we create the tables, and we create the **session**.
-
-    Then we `yield` the `session` object.
-
-4. The thing that we `return` or `yield` is what will be available to the test function, in this case, the `session` object.
-
-    Here we use `yield` so that **pytest** comes back to execute "the rest of the code" in this function once the testing function is done.
-
-    We don't have any more visible "rest of the code" after the `yield`, but we have the end of the `with` block that will close the **session**.
-
-    By using `yield`, pytest will:
-
-    * run the first part
-    * create the **session** object
-    * give it to the test function
-    * run the test function
-    * once the test function is done, it will continue here, right after the `yield`, and will correctly close the **session** object in the end of the `with` block.
-
-5. Now, in the test function, to tell **pytest** that this test wants to get the fixture, instead of declaring something like in FastAPI with:
-
-    ```Python
-    session: Session = Depends(session_fixture)
-    ```
-
-    ...the way we tell pytest what is the fixture that we want is by using the **exact same name** of the fixture.
-
-    In this case, we named it `session`, so the parameter has to be exactly named `session` for it to work.
-
-    We also add the type annotation `session: Session` so that we can get autocompletion and inline error checks in our editor.
-
-6. Now in the dependency override function, we just return the same `session` object that came from outside it.
-
-    The `session` object comes from the parameter passed to the test function, and we just re-use it and return it here in the dependency override.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_006.md b/docs_src/tutorial/fastapi/app_testing/tutorial001/annotations/en/test_main_006.md
deleted file mode 100644 (file)
index d44a3b6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-1. Create the new fixture named `"client"`.
-
-2. This **client fixture**, in turn, also requires the **session fixture**.
-
-3. Now we create the **dependency override** inside the client fixture.
-
-4. Set the **dependency override** in the `app.dependency_overrides` dictionary.
-
-5. Create the `TestClient` with the **FastAPI** `app`.
-
-6. `yield` the `TestClient` instance.
-
-    By using `yield`, after the test function is done, pytest will come back to execute the rest of the code after `yield`.
-
-7. This is the cleanup code, after `yield`, and after the test function is done.
-
-    Here we clear the dependency overrides (here it's only one) in the FastAPI `app`.
-
-8. Now the test function requires the **client fixture**.
-
-    And inside the test function, the code is quite **simple**, we just use the `TestClient` to make requests to the API, check the data, and that's it.
-
-    The fixtures take care of all the **setup** and **cleanup** code.
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py
deleted file mode 100644 (file)
index f0a2559..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-from typing import List, Optional
-
-from fastapi import Depends, FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def get_session():
-    with Session(engine) as session:
-        yield session
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
-    db_hero = Hero.model_validate(hero)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-    return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(
-    *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
-):
-    db_hero = session.get(Hero, hero_id)
-    if not db_hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    hero_data = hero.model_dump(exclude_unset=True)
-    db_hero.sqlmodel_update(hero_data)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.delete("/heroes/{hero_id}")
-def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    session.delete(hero)
-    session.commit()
-    return {"ok": True}
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_extra_coverage.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_extra_coverage.py
deleted file mode 100644 (file)
index 1d8153a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-from fastapi.testclient import TestClient
-from sqlalchemy import Inspector, inspect
-from sqlmodel import Session, create_engine
-
-from . import main as app_mod
-from .test_main import client_fixture, session_fixture
-
-assert client_fixture, "This keeps the client fixture used below"
-assert session_fixture, "This keeps the session fixture used by client_fixture"
-
-
-def test_startup():
-    app_mod.engine = create_engine("sqlite://")
-    app_mod.on_startup()
-    insp: Inspector = inspect(app_mod.engine)
-    assert insp.has_table(str(app_mod.Hero.__tablename__))
-
-
-def test_get_session():
-    app_mod.engine = create_engine("sqlite://")
-    for session in app_mod.get_session():
-        assert isinstance(session, Session)
-        assert session.bind == app_mod.engine
-
-
-def test_read_hero_not_found(client: TestClient):
-    response = client.get("/heroes/9000")
-    assert response.status_code == 404
-
-
-def test_update_hero_not_found(client: TestClient):
-    response = client.patch("/heroes/9000", json={"name": "Very-Rusty-Man"})
-    assert response.status_code == 404
-
-
-def test_delete_hero_not_found(client: TestClient):
-    response = client.delete("/heroes/9000")
-    assert response.status_code == 404
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main.py
deleted file mode 100644 (file)
index 435787c..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-import pytest
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-from sqlmodel.pool import StaticPool
-
-from .main import Hero, app, get_session
-
-
-@pytest.fixture(name="session")
-def session_fixture():
-    engine = create_engine(
-        "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool
-    )
-    SQLModel.metadata.create_all(engine)
-    with Session(engine) as session:
-        yield session
-
-
-@pytest.fixture(name="client")
-def client_fixture(session: Session):
-    def get_session_override():
-        return session
-
-    app.dependency_overrides[get_session] = get_session_override
-    client = TestClient(app)
-    yield client
-    app.dependency_overrides.clear()
-
-
-def test_create_hero(client: TestClient):
-    response = client.post(
-        "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-    )
-    data = response.json()
-
-    assert response.status_code == 200
-    assert data["name"] == "Deadpond"
-    assert data["secret_name"] == "Dive Wilson"
-    assert data["age"] is None
-    assert data["id"] is not None
-
-
-def test_create_hero_incomplete(client: TestClient):
-    # No secret_name
-    response = client.post("/heroes/", json={"name": "Deadpond"})
-    assert response.status_code == 422
-
-
-def test_create_hero_invalid(client: TestClient):
-    # secret_name has an invalid type
-    response = client.post(
-        "/heroes/",
-        json={
-            "name": "Deadpond",
-            "secret_name": {"message": "Do you wanna know my secret identity?"},
-        },
-    )
-    assert response.status_code == 422
-
-
-def test_read_heroes(session: Session, client: TestClient):
-    hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
-    hero_2 = Hero(name="Rusty-Man", secret_name="Tommy Sharp", age=48)
-    session.add(hero_1)
-    session.add(hero_2)
-    session.commit()
-
-    response = client.get("/heroes/")
-    data = response.json()
-
-    assert response.status_code == 200
-
-    assert len(data) == 2
-    assert data[0]["name"] == hero_1.name
-    assert data[0]["secret_name"] == hero_1.secret_name
-    assert data[0]["age"] == hero_1.age
-    assert data[0]["id"] == hero_1.id
-    assert data[1]["name"] == hero_2.name
-    assert data[1]["secret_name"] == hero_2.secret_name
-    assert data[1]["age"] == hero_2.age
-    assert data[1]["id"] == hero_2.id
-
-
-def test_read_hero(session: Session, client: TestClient):
-    hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
-    session.add(hero_1)
-    session.commit()
-
-    response = client.get(f"/heroes/{hero_1.id}")
-    data = response.json()
-
-    assert response.status_code == 200
-    assert data["name"] == hero_1.name
-    assert data["secret_name"] == hero_1.secret_name
-    assert data["age"] == hero_1.age
-    assert data["id"] == hero_1.id
-
-
-def test_update_hero(session: Session, client: TestClient):
-    hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
-    session.add(hero_1)
-    session.commit()
-
-    response = client.patch(f"/heroes/{hero_1.id}", json={"name": "Deadpuddle"})
-    data = response.json()
-
-    assert response.status_code == 200
-    assert data["name"] == "Deadpuddle"
-    assert data["secret_name"] == "Dive Wilson"
-    assert data["age"] is None
-    assert data["id"] == hero_1.id
-
-
-def test_delete_hero(session: Session, client: TestClient):
-    hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
-    session.add(hero_1)
-    session.commit()
-
-    response = client.delete(f"/heroes/{hero_1.id}")
-
-    hero_in_db = session.get(Hero, hero_1.id)
-
-    assert response.status_code == 200
-
-    assert hero_in_db is None
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_001.py
deleted file mode 100644 (file)
index 3ae4077..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-
-from .main import app, get_session  # (1)!
-
-
-def test_create_hero():
-    engine = create_engine(
-        "sqlite:///testing.db", connect_args={"check_same_thread": False}
-    )
-    SQLModel.metadata.create_all(engine)
-
-    with Session(engine) as session:
-
-        def get_session_override():
-            return session
-
-        app.dependency_overrides[get_session] = get_session_override
-
-        client = TestClient(app)  # (2)!
-
-        response = client.post(  # (3)!
-            "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-        )
-        app.dependency_overrides.clear()
-        data = response.json()  # (4)!
-
-        assert response.status_code == 200  # (5)!
-        assert data["name"] == "Deadpond"  # (6)!
-        assert data["secret_name"] == "Dive Wilson"  # (7)!
-        assert data["age"] is None  # (8)!
-        assert data["id"] is not None  # (9)!
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_002.py
deleted file mode 100644 (file)
index 727580b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-
-from .main import app, get_session  # (1)!
-
-
-def test_create_hero():
-    engine = create_engine(
-        "sqlite:///testing.db", connect_args={"check_same_thread": False}
-    )
-    SQLModel.metadata.create_all(engine)
-
-    with Session(engine) as session:
-
-        def get_session_override():  # (2)!
-            return session  # (3)!
-
-        app.dependency_overrides[get_session] = get_session_override  # (4)!
-
-        client = TestClient(app)
-
-        response = client.post(
-            "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-        )
-        app.dependency_overrides.clear()  # (5)!
-        data = response.json()
-
-        assert response.status_code == 200
-        assert data["name"] == "Deadpond"
-        assert data["secret_name"] == "Dive Wilson"
-        assert data["age"] is None
-        assert data["id"] is not None
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_003.py
deleted file mode 100644 (file)
index 465c525..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-
-from .main import app, get_session  # (1)!
-
-
-def test_create_hero():
-    engine = create_engine(  # (2)!
-        "sqlite:///testing.db", connect_args={"check_same_thread": False}
-    )
-    SQLModel.metadata.create_all(engine)  # (3)!
-
-    with Session(engine) as session:  # (4)!
-
-        def get_session_override():
-            return session  # (5)!
-
-        app.dependency_overrides[get_session] = get_session_override  # (4)!
-
-        client = TestClient(app)
-
-        response = client.post(
-            "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-        )
-        app.dependency_overrides.clear()
-        data = response.json()
-
-        assert response.status_code == 200
-        assert data["name"] == "Deadpond"
-        assert data["secret_name"] == "Dive Wilson"
-        assert data["age"] is None
-        assert data["id"] is not None
-    # (6)!
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_004.py
deleted file mode 100644 (file)
index b770a9a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-from sqlmodel.pool import StaticPool  # (1)!
-
-from .main import app, get_session
-
-
-def test_create_hero():
-    engine = create_engine(
-        "sqlite://",  # (2)!
-        connect_args={"check_same_thread": False},
-        poolclass=StaticPool,  # (3)!
-    )
-    SQLModel.metadata.create_all(engine)
-
-    with Session(engine) as session:
-
-        def get_session_override():
-            return session
-
-        app.dependency_overrides[get_session] = get_session_override
-
-        client = TestClient(app)
-
-        response = client.post(
-            "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-        )
-        app.dependency_overrides.clear()
-        data = response.json()
-
-        assert response.status_code == 200
-        assert data["name"] == "Deadpond"
-        assert data["secret_name"] == "Dive Wilson"
-        assert data["age"] is None
-        assert data["id"] is not None
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_005.py
deleted file mode 100644 (file)
index f653eef..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-import pytest  # (1)!
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-from sqlmodel.pool import StaticPool
-
-from .main import app, get_session
-
-
-@pytest.fixture(name="session")  # (2)!
-def session_fixture():  # (3)!
-    engine = create_engine(
-        "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool
-    )
-    SQLModel.metadata.create_all(engine)
-    with Session(engine) as session:
-        yield session  # (4)!
-
-
-def test_create_hero(session: Session):  # (5)!
-    def get_session_override():
-        return session  # (6)!
-
-    app.dependency_overrides[get_session] = get_session_override
-
-    client = TestClient(app)
-
-    response = client.post(
-        "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-    )
-    app.dependency_overrides.clear()
-    data = response.json()
-
-    assert response.status_code == 200
-    assert data["name"] == "Deadpond"
-    assert data["secret_name"] == "Dive Wilson"
-    assert data["age"] is None
-    assert data["id"] is not None
diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/test_main_006.py
deleted file mode 100644 (file)
index 8dbfd45..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-import pytest
-from fastapi.testclient import TestClient
-from sqlmodel import Session, SQLModel, create_engine
-from sqlmodel.pool import StaticPool
-
-from .main import app, get_session
-
-
-@pytest.fixture(name="session")
-def session_fixture():
-    engine = create_engine(
-        "sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool
-    )
-    SQLModel.metadata.create_all(engine)
-    with Session(engine) as session:
-        yield session
-
-
-@pytest.fixture(name="client")  # (1)!
-def client_fixture(session: Session):  # (2)!
-    def get_session_override():  # (3)!
-        return session
-
-    app.dependency_overrides[get_session] = get_session_override  # (4)!
-
-    client = TestClient(app)  # (5)!
-    yield client  # (6)!
-    app.dependency_overrides.clear()  # (7)!
-
-
-def test_create_hero(client: TestClient):  # (8)!
-    response = client.post(
-        "/heroes/", json={"name": "Deadpond", "secret_name": "Dive Wilson"}
-    )
-    data = response.json()
-
-    assert response.status_code == 200
-    assert data["name"] == "Deadpond"
-    assert data["secret_name"] == "Dive Wilson"
-    assert data["age"] is None
-    assert data["id"] is not None
diff --git a/docs_src/tutorial/fastapi/delete/tutorial001.py b/docs_src/tutorial/fastapi/delete/tutorial001.py
deleted file mode 100644 (file)
index 977882c..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-        return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(hero_id: int, hero: HeroUpdate):
-    with Session(engine) as session:
-        db_hero = session.get(Hero, hero_id)
-        if not db_hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        hero_data = hero.model_dump(exclude_unset=True)
-        db_hero.sqlmodel_update(hero_data)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.delete("/heroes/{hero_id}")
-def delete_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        session.delete(hero)
-        session.commit()
-        return {"ok": True}
diff --git a/docs_src/tutorial/fastapi/limit_and_offset/tutorial001.py b/docs_src/tutorial/fastapi/limit_and_offset/tutorial001.py
deleted file mode 100644 (file)
index ccf3d77..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-        return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        return hero
diff --git a/docs_src/tutorial/fastapi/multiple_models/tutorial001.py b/docs_src/tutorial/fastapi/multiple_models/tutorial001.py
deleted file mode 100644 (file)
index 42ac805..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class HeroCreate(SQLModel):
-    name: str
-    secret_name: str
-    age: Optional[int] = None
-
-
-class HeroPublic(SQLModel):
-    id: int
-    name: str
-    secret_name: str
-    age: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes():
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero)).all()
-        return heroes
diff --git a/docs_src/tutorial/fastapi/multiple_models/tutorial002.py b/docs_src/tutorial/fastapi/multiple_models/tutorial002.py
deleted file mode 100644 (file)
index 79c71f1..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes():
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero)).all()
-        return heroes
diff --git a/docs_src/tutorial/fastapi/read_one/tutorial001.py b/docs_src/tutorial/fastapi/read_one/tutorial001.py
deleted file mode 100644 (file)
index a399451..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI, HTTPException
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes():
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero)).all()
-        return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        return hero
diff --git a/docs_src/tutorial/fastapi/relationships/tutorial001.py b/docs_src/tutorial/fastapi/relationships/tutorial001.py
deleted file mode 100644 (file)
index 59b4473..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-from typing import List, Optional
-
-from fastapi import Depends, FastAPI, HTTPException, Query
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class TeamBase(SQLModel):
-    name: str = Field(index=True)
-    headquarters: str
-
-
-class Team(TeamBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class TeamCreate(TeamBase):
-    pass
-
-
-class TeamPublic(TeamBase):
-    id: int
-
-
-class TeamUpdate(SQLModel):
-    id: Optional[int] = None
-    name: Optional[str] = None
-    headquarters: Optional[str] = None
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-    team_id: Optional[int] = None
-
-
-class HeroPublicWithTeam(HeroPublic):
-    team: Optional[TeamPublic] = None
-
-
-class TeamPublicWithHeroes(TeamPublic):
-    heroes: List[HeroPublic] = []
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def get_session():
-    with Session(engine) as session:
-        yield session
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
-    db_hero = Hero.model_validate(hero)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-    return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublicWithTeam)
-def read_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(
-    *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
-):
-    db_hero = session.get(Hero, hero_id)
-    if not db_hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    hero_data = hero.model_dump(exclude_unset=True)
-    db_hero.sqlmodel_update(hero_data)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.delete("/heroes/{hero_id}")
-def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    session.delete(hero)
-    session.commit()
-    return {"ok": True}
-
-
-@app.post("/teams/", response_model=TeamPublic)
-def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
-    db_team = Team.model_validate(team)
-    session.add(db_team)
-    session.commit()
-    session.refresh(db_team)
-    return db_team
-
-
-@app.get("/teams/", response_model=List[TeamPublic])
-def read_teams(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    teams = session.exec(select(Team).offset(offset).limit(limit)).all()
-    return teams
-
-
-@app.get("/teams/{team_id}", response_model=TeamPublicWithHeroes)
-def read_team(*, team_id: int, session: Session = Depends(get_session)):
-    team = session.get(Team, team_id)
-    if not team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    return team
-
-
-@app.patch("/teams/{team_id}", response_model=TeamPublic)
-def update_team(
-    *,
-    session: Session = Depends(get_session),
-    team_id: int,
-    team: TeamUpdate,
-):
-    db_team = session.get(Team, team_id)
-    if not db_team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    team_data = team.model_dump(exclude_unset=True)
-    db_team.sqlmodel_update(team_data)
-    session.add(db_team)
-    session.commit()
-    session.refresh(db_team)
-    return db_team
-
-
-@app.delete("/teams/{team_id}")
-def delete_team(*, session: Session = Depends(get_session), team_id: int):
-    team = session.get(Team, team_id)
-    if not team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    session.delete(team)
-    session.commit()
-    return {"ok": True}
diff --git a/docs_src/tutorial/fastapi/response_model/tutorial001.py b/docs_src/tutorial/fastapi/response_model/tutorial001.py
deleted file mode 100644 (file)
index 57d8738..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=Hero)
-def create_hero(hero: Hero):
-    with Session(engine) as session:
-        session.add(hero)
-        session.commit()
-        session.refresh(hero)
-        return hero
-
-
-@app.get("/heroes/", response_model=List[Hero])
-def read_heroes():
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero)).all()
-        return heroes
diff --git a/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py b/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py
deleted file mode 100644 (file)
index f0a2559..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-from typing import List, Optional
-
-from fastapi import Depends, FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def get_session():
-    with Session(engine) as session:
-        yield session
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
-    db_hero = Hero.model_validate(hero)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-    return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(
-    *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
-):
-    db_hero = session.get(Hero, hero_id)
-    if not db_hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    hero_data = hero.model_dump(exclude_unset=True)
-    db_hero.sqlmodel_update(hero_data)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.delete("/heroes/{hero_id}")
-def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    session.delete(hero)
-    session.commit()
-    return {"ok": True}
diff --git a/docs_src/tutorial/fastapi/teams/tutorial001.py b/docs_src/tutorial/fastapi/teams/tutorial001.py
deleted file mode 100644 (file)
index 49dd830..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-from typing import List, Optional
-
-from fastapi import Depends, FastAPI, HTTPException, Query
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class TeamBase(SQLModel):
-    name: str = Field(index=True)
-    headquarters: str
-
-
-class Team(TeamBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class TeamCreate(TeamBase):
-    pass
-
-
-class TeamPublic(TeamBase):
-    id: int
-
-
-class TeamUpdate(SQLModel):
-    name: Optional[str] = None
-    headquarters: Optional[str] = None
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-    team_id: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def get_session():
-    with Session(engine) as session:
-        yield session
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
-    db_hero = Hero.model_validate(hero)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-    return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(
-    *, session: Session = Depends(get_session), hero_id: int, hero: HeroUpdate
-):
-    db_hero = session.get(Hero, hero_id)
-    if not db_hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    hero_data = hero.model_dump(exclude_unset=True)
-    db_hero.sqlmodel_update(hero_data)
-    session.add(db_hero)
-    session.commit()
-    session.refresh(db_hero)
-    return db_hero
-
-
-@app.delete("/heroes/{hero_id}")
-def delete_hero(*, session: Session = Depends(get_session), hero_id: int):
-    hero = session.get(Hero, hero_id)
-    if not hero:
-        raise HTTPException(status_code=404, detail="Hero not found")
-    session.delete(hero)
-    session.commit()
-    return {"ok": True}
-
-
-@app.post("/teams/", response_model=TeamPublic)
-def create_team(*, session: Session = Depends(get_session), team: TeamCreate):
-    db_team = Team.model_validate(team)
-    session.add(db_team)
-    session.commit()
-    session.refresh(db_team)
-    return db_team
-
-
-@app.get("/teams/", response_model=List[TeamPublic])
-def read_teams(
-    *,
-    session: Session = Depends(get_session),
-    offset: int = 0,
-    limit: int = Query(default=100, le=100),
-):
-    teams = session.exec(select(Team).offset(offset).limit(limit)).all()
-    return teams
-
-
-@app.get("/teams/{team_id}", response_model=TeamPublic)
-def read_team(*, team_id: int, session: Session = Depends(get_session)):
-    team = session.get(Team, team_id)
-    if not team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    return team
-
-
-@app.patch("/teams/{team_id}", response_model=TeamPublic)
-def update_team(
-    *,
-    session: Session = Depends(get_session),
-    team_id: int,
-    team: TeamUpdate,
-):
-    db_team = session.get(Team, team_id)
-    if not db_team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    team_data = team.model_dump(exclude_unset=True)
-    db_team.sqlmodel_update(team_data)
-    session.add(db_team)
-    session.commit()
-    session.refresh(db_team)
-    return db_team
-
-
-@app.delete("/teams/{team_id}")
-def delete_team(*, session: Session = Depends(get_session), team_id: int):
-    team = session.get(Team, team_id)
-    if not team:
-        raise HTTPException(status_code=404, detail="Team not found")
-    session.delete(team)
-    session.commit()
-    return {"ok": True}
diff --git a/docs_src/tutorial/fastapi/update/tutorial001.py b/docs_src/tutorial/fastapi/update/tutorial001.py
deleted file mode 100644 (file)
index 6a02f6c..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-
-
-class HeroCreate(HeroBase):
-    pass
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    with Session(engine) as session:
-        db_hero = Hero.model_validate(hero)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-        return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(hero_id: int, hero: HeroUpdate):
-    with Session(engine) as session:
-        db_hero = session.get(Hero, hero_id)
-        if not db_hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        hero_data = hero.model_dump(exclude_unset=True)
-        db_hero.sqlmodel_update(hero_data)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
diff --git a/docs_src/tutorial/fastapi/update/tutorial002.py b/docs_src/tutorial/fastapi/update/tutorial002.py
deleted file mode 100644 (file)
index c8838ae..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-from typing import List, Optional
-
-from fastapi import FastAPI, HTTPException, Query
-from sqlmodel import Field, Session, SQLModel, create_engine, select
-
-
-class HeroBase(SQLModel):
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-
-class Hero(HeroBase, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    hashed_password: str = Field()
-
-
-class HeroCreate(HeroBase):
-    password: str
-
-
-class HeroPublic(HeroBase):
-    id: int
-
-
-class HeroUpdate(SQLModel):
-    name: Optional[str] = None
-    secret_name: Optional[str] = None
-    age: Optional[int] = None
-    password: Optional[str] = None
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-connect_args = {"check_same_thread": False}
-engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def hash_password(password: str) -> str:
-    # Use something like passlib here
-    return f"not really hashed {password} hehehe"
-
-
-app = FastAPI()
-
-
-@app.on_event("startup")
-def on_startup():
-    create_db_and_tables()
-
-
-@app.post("/heroes/", response_model=HeroPublic)
-def create_hero(hero: HeroCreate):
-    hashed_password = hash_password(hero.password)
-    with Session(engine) as session:
-        extra_data = {"hashed_password": hashed_password}
-        db_hero = Hero.model_validate(hero, update=extra_data)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
-
-
-@app.get("/heroes/", response_model=List[HeroPublic])
-def read_heroes(offset: int = 0, limit: int = Query(default=100, le=100)):
-    with Session(engine) as session:
-        heroes = session.exec(select(Hero).offset(offset).limit(limit)).all()
-        return heroes
-
-
-@app.get("/heroes/{hero_id}", response_model=HeroPublic)
-def read_hero(hero_id: int):
-    with Session(engine) as session:
-        hero = session.get(Hero, hero_id)
-        if not hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        return hero
-
-
-@app.patch("/heroes/{hero_id}", response_model=HeroPublic)
-def update_hero(hero_id: int, hero: HeroUpdate):
-    with Session(engine) as session:
-        db_hero = session.get(Hero, hero_id)
-        if not db_hero:
-            raise HTTPException(status_code=404, detail="Hero not found")
-        hero_data = hero.model_dump(exclude_unset=True)
-        extra_data = {}
-        if "password" in hero_data:
-            password = hero_data["password"]
-            hashed_password = hash_password(password)
-            extra_data["hashed_password"] = hashed_password
-        db_hero.sqlmodel_update(hero_data, update=extra_data)
-        session.add(db_hero)
-        session.commit()
-        session.refresh(db_hero)
-        return db_hero
diff --git a/docs_src/tutorial/many_to_many/tutorial001.py b/docs_src/tutorial/many_to_many/tutorial001.py
deleted file mode 100644 (file)
index 79f9e79..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine
-
-
-class HeroTeamLink(SQLModel, table=True):
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", primary_key=True
-    )
-    hero_id: Optional[int] = Field(
-        default=None, foreign_key="hero.id", primary_key=True
-    )
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="teams", link_model=HeroTeamLink)
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    teams: List[Team] = Relationship(back_populates="heroes", link_model=HeroTeamLink)
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond",
-            secret_name="Dive Wilson",
-            teams=[team_z_force, team_preventers],
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man",
-            secret_name="Tommy Sharp",
-            age=48,
-            teams=[team_preventers],
-        )
-        hero_spider_boy = Hero(
-            name="Spider-Boy", secret_name="Pedro Parqueador", teams=[team_preventers]
-        )
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Deadpond:", hero_deadpond)
-        print("Deadpond teams:", hero_deadpond.teams)
-        print("Rusty-Man:", hero_rusty_man)
-        print("Rusty-Man Teams:", hero_rusty_man.teams)
-        print("Spider-Boy:", hero_spider_boy)
-        print("Spider-Boy Teams:", hero_spider_boy.teams)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/many_to_many/tutorial002.py b/docs_src/tutorial/many_to_many/tutorial002.py
deleted file mode 100644 (file)
index 9845340..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class HeroTeamLink(SQLModel, table=True):
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", primary_key=True
-    )
-    hero_id: Optional[int] = Field(
-        default=None, foreign_key="hero.id", primary_key=True
-    )
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="teams", link_model=HeroTeamLink)
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    teams: List[Team] = Relationship(back_populates="heroes", link_model=HeroTeamLink)
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond",
-            secret_name="Dive Wilson",
-            teams=[team_z_force, team_preventers],
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man",
-            secret_name="Tommy Sharp",
-            age=48,
-            teams=[team_preventers],
-        )
-        hero_spider_boy = Hero(
-            name="Spider-Boy", secret_name="Pedro Parqueador", teams=[team_preventers]
-        )
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Deadpond:", hero_deadpond)
-        print("Deadpond teams:", hero_deadpond.teams)
-        print("Rusty-Man:", hero_rusty_man)
-        print("Rusty-Man Teams:", hero_rusty_man.teams)
-        print("Spider-Boy:", hero_spider_boy)
-        print("Spider-Boy Teams:", hero_spider_boy.teams)
-
-
-def update_heroes():
-    with Session(engine) as session:
-        hero_spider_boy = session.exec(
-            select(Hero).where(Hero.name == "Spider-Boy")
-        ).one()
-        team_z_force = session.exec(select(Team).where(Team.name == "Z-Force")).one()
-
-        team_z_force.heroes.append(hero_spider_boy)
-        session.add(team_z_force)
-        session.commit()
-
-        print("Updated Spider-Boy's Teams:", hero_spider_boy.teams)
-        print("Z-Force heroes:", team_z_force.heroes)
-
-        hero_spider_boy.teams.remove(team_z_force)
-        session.add(team_z_force)
-        session.commit()
-
-        print("Reverted Z-Force's heroes:", team_z_force.heroes)
-        print("Reverted Spider-Boy's teams:", hero_spider_boy.teams)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    update_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/many_to_many/tutorial003.py b/docs_src/tutorial/many_to_many/tutorial003.py
deleted file mode 100644 (file)
index 6c23878..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class HeroTeamLink(SQLModel, table=True):
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", primary_key=True
-    )
-    hero_id: Optional[int] = Field(
-        default=None, foreign_key="hero.id", primary_key=True
-    )
-    is_training: bool = False
-
-    team: "Team" = Relationship(back_populates="hero_links")
-    hero: "Hero" = Relationship(back_populates="team_links")
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    hero_links: List[HeroTeamLink] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_links: List[HeroTeamLink] = Relationship(back_populates="hero")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond",
-            secret_name="Dive Wilson",
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man",
-            secret_name="Tommy Sharp",
-            age=48,
-        )
-        hero_spider_boy = Hero(
-            name="Spider-Boy",
-            secret_name="Pedro Parqueador",
-        )
-        deadpond_team_z_link = HeroTeamLink(team=team_z_force, hero=hero_deadpond)
-        deadpond_preventers_link = HeroTeamLink(
-            team=team_preventers, hero=hero_deadpond, is_training=True
-        )
-        spider_boy_preventers_link = HeroTeamLink(
-            team=team_preventers, hero=hero_spider_boy, is_training=True
-        )
-        rusty_man_preventers_link = HeroTeamLink(
-            team=team_preventers, hero=hero_rusty_man
-        )
-
-        session.add(deadpond_team_z_link)
-        session.add(deadpond_preventers_link)
-        session.add(spider_boy_preventers_link)
-        session.add(rusty_man_preventers_link)
-        session.commit()
-
-        for link in team_z_force.hero_links:
-            print("Z-Force hero:", link.hero, "is training:", link.is_training)
-
-        for link in team_preventers.hero_links:
-            print("Preventers hero:", link.hero, "is training:", link.is_training)
-
-
-def update_heroes():
-    with Session(engine) as session:
-        hero_spider_boy = session.exec(
-            select(Hero).where(Hero.name == "Spider-Boy")
-        ).one()
-        team_z_force = session.exec(select(Team).where(Team.name == "Z-Force")).one()
-
-        spider_boy_z_force_link = HeroTeamLink(
-            team=team_z_force, hero=hero_spider_boy, is_training=True
-        )
-        team_z_force.hero_links.append(spider_boy_z_force_link)
-        session.add(team_z_force)
-        session.commit()
-
-        print("Updated Spider-Boy's Teams:", hero_spider_boy.team_links)
-        print("Z-Force heroes:", team_z_force.hero_links)
-
-        for link in hero_spider_boy.team_links:
-            if link.team.name == "Preventers":
-                link.is_training = False
-
-        session.add(hero_spider_boy)
-        session.commit()
-
-        for link in hero_spider_boy.team_links:
-            print("Spider-Boy team:", link.team, "is training:", link.is_training)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    update_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py b/docs_src/tutorial/relationship_attributes/back_populates/tutorial001.py
deleted file mode 100644 (file)
index 39230cb..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship()
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship()
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-        hero_tarantula = Hero(name="Tarantula", secret_name="Natalia Roman-on", age=32)
-        hero_dr_weird = Hero(name="Dr. Weird", secret_name="Steve Weird", age=36)
-        hero_cap = Hero(
-            name="Captain North America", secret_name="Esteban Rogelios", age=93
-        )
-
-        team_preventers.heroes.append(hero_tarantula)
-        team_preventers.heroes.append(hero_dr_weird)
-        team_preventers.heroes.append(hero_cap)
-        session.add(team_preventers)
-        session.commit()
-        session.refresh(hero_tarantula)
-        session.refresh(hero_dr_weird)
-        session.refresh(hero_cap)
-        print("Preventers new hero:", hero_tarantula)
-        print("Preventers new hero:", hero_dr_weird)
-        print("Preventers new hero:", hero_cap)
-
-
-def select_heroes():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Preventers")
-        result = session.exec(statement)
-        team_preventers = result.one()
-
-        print("Preventers heroes:", team_preventers.heroes)
-
-
-def update_heroes():
-    with Session(engine) as session:
-        hero_spider_boy = session.exec(
-            select(Hero).where(Hero.name == "Spider-Boy")
-        ).one()
-
-        preventers_team = session.exec(
-            select(Team).where(Team.name == "Preventers")
-        ).one()
-
-        print("Hero Spider-Boy:", hero_spider_boy)
-        print("Preventers Team:", preventers_team)
-        print("Preventers Team Heroes:", preventers_team.heroes)
-
-        hero_spider_boy.team = None
-
-        print("Spider-Boy without team:", hero_spider_boy)
-
-        print("Preventers Team Heroes again:", preventers_team.heroes)
-
-        session.add(hero_spider_boy)
-        session.commit()
-        print("After committing")
-
-        session.refresh(hero_spider_boy)
-        print("Spider-Boy after commit:", hero_spider_boy)
-
-        print("Preventers Team Heroes after commit:", preventers_team.heroes)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    select_heroes()
-    update_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py b/docs_src/tutorial/relationship_attributes/back_populates/tutorial002.py
deleted file mode 100644 (file)
index a1add4b..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-        hero_tarantula = Hero(name="Tarantula", secret_name="Natalia Roman-on", age=32)
-        hero_dr_weird = Hero(name="Dr. Weird", secret_name="Steve Weird", age=36)
-        hero_cap = Hero(
-            name="Captain North America", secret_name="Esteban Rogelios", age=93
-        )
-
-        team_preventers.heroes.append(hero_tarantula)
-        team_preventers.heroes.append(hero_dr_weird)
-        team_preventers.heroes.append(hero_cap)
-        session.add(team_preventers)
-        session.commit()
-        session.refresh(hero_tarantula)
-        session.refresh(hero_dr_weird)
-        session.refresh(hero_cap)
-        print("Preventers new hero:", hero_tarantula)
-        print("Preventers new hero:", hero_dr_weird)
-        print("Preventers new hero:", hero_cap)
-
-
-def select_heroes():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Preventers")
-        result = session.exec(statement)
-        team_preventers = result.one()
-
-        print("Preventers heroes:", team_preventers.heroes)
-
-
-def update_heroes():
-    with Session(engine) as session:
-        hero_spider_boy = session.exec(
-            select(Hero).where(Hero.name == "Spider-Boy")
-        ).one()
-
-        preventers_team = session.exec(
-            select(Team).where(Team.name == "Preventers")
-        ).one()
-
-        print("Hero Spider-Boy:", hero_spider_boy)
-        print("Preventers Team:", preventers_team)
-        print("Preventers Team Heroes:", preventers_team.heroes)
-
-        hero_spider_boy.team = None
-
-        print("Spider-Boy without team:", hero_spider_boy)
-
-        print("Preventers Team Heroes again:", preventers_team.heroes)
-
-        session.add(hero_spider_boy)
-        session.commit()
-        print("After committing")
-
-        session.refresh(hero_spider_boy)
-        print("Spider-Boy after commit:", hero_spider_boy)
-
-        print("Preventers Team Heroes after commit:", preventers_team.heroes)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    select_heroes()
-    update_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/back_populates/tutorial003.py b/docs_src/tutorial/relationship_attributes/back_populates/tutorial003.py
deleted file mode 100644 (file)
index 98e1970..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, SQLModel, create_engine
-
-
-class Weapon(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-
-    hero: "Hero" = Relationship(back_populates="weapon")
-
-
-class Power(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-
-    hero_id: int = Field(foreign_key="hero.id")
-    hero: "Hero" = Relationship(back_populates="powers")
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-    weapon_id: Optional[int] = Field(default=None, foreign_key="weapon.id")
-    weapon: Optional[Weapon] = Relationship(back_populates="hero")
-
-    powers: List[Power] = Relationship(back_populates="hero")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def main():
-    create_db_and_tables()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial001.py b/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial001.py
deleted file mode 100644 (file)
index 877aeb3..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team", cascade_delete=True)
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", ondelete="CASCADE"
-    )
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-
-def delete_team():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        session.delete(team)
-        session.commit()
-        print("Deleted team:", team)
-
-
-def select_deleted_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Black Lion")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Black Lion not found:", hero)
-
-        statement = select(Hero).where(Hero.name == "Princess Sure-E")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Princess Sure-E not found:", hero)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    delete_team()
-    select_deleted_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial002.py b/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial002.py
deleted file mode 100644 (file)
index ac97a20..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", ondelete="SET NULL"
-    )
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-
-def delete_team():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        session.delete(team)
-        session.commit()
-        print("Deleted team:", team)
-
-
-def select_deleted_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Black Lion")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Black Lion has no team:", hero)
-
-        statement = select(Hero).where(Hero.name == "Princess Sure-E")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Princess Sure-E has no team:", hero)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    delete_team()
-    select_deleted_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial003.py b/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial003.py
deleted file mode 100644 (file)
index 0424f75..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select, text
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team", passive_deletes="all")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", ondelete="SET NULL"
-    )
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-    with engine.connect() as connection:
-        connection.execute(text("PRAGMA foreign_keys=ON"))  # for SQLite only
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-
-def delete_team():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        session.delete(team)
-        session.commit()
-        print("Deleted team:", team)
-
-
-def select_deleted_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Black Lion")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Black Lion has no team:", hero)
-
-        statement = select(Hero).where(Hero.name == "Princess Sure-E")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Princess Sure-E has no team:", hero)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    delete_team()
-    select_deleted_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial004.py b/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial004.py
deleted file mode 100644 (file)
index 00c5ac1..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select, text
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team", passive_deletes="all")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", ondelete="RESTRICT"
-    )
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-    with engine.connect() as connection:
-        connection.execute(text("PRAGMA foreign_keys=ON"))  # for SQLite only
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-
-def delete_team():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        session.delete(team)
-        session.commit()
-        print("Deleted team:", team)
-
-
-def select_deleted_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Black Lion")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Black Lion has no team:", hero)
-
-        statement = select(Hero).where(Hero.name == "Princess Sure-E")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Princess Sure-E has no team:", hero)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    delete_team()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial005.py b/docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial005.py
deleted file mode 100644 (file)
index b46a778..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select, text
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team", passive_deletes="all")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(
-        default=None, foreign_key="team.id", ondelete="RESTRICT"
-    )
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-    with engine.connect() as connection:
-        connection.execute(text("PRAGMA foreign_keys=ON"))  # for SQLite only
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-
-def remove_team_heroes():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        team.heroes.clear()
-        session.add(team)
-        session.commit()
-        session.refresh(team)
-        print("Team with removed heroes:", team)
-
-
-def delete_team():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Wakaland")
-        team = session.exec(statement).one()
-        session.delete(team)
-        session.commit()
-        print("Deleted team:", team)
-
-
-def select_deleted_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Black Lion")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Black Lion has no team:", hero)
-
-        statement = select(Hero).where(Hero.name == "Princess Sure-E")
-        result = session.exec(statement)
-        hero = result.first()
-        print("Princess Sure-E has no team:", hero)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    remove_team_heroes()
-    delete_team()
-    select_deleted_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py b/docs_src/tutorial/relationship_attributes/create_and_update_relationships/tutorial001.py
deleted file mode 100644 (file)
index 73c68cf..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-        hero_tarantula = Hero(name="Tarantula", secret_name="Natalia Roman-on", age=32)
-        hero_dr_weird = Hero(name="Dr. Weird", secret_name="Steve Weird", age=36)
-        hero_cap = Hero(
-            name="Captain North America", secret_name="Esteban Rogelios", age=93
-        )
-
-        team_preventers.heroes.append(hero_tarantula)
-        team_preventers.heroes.append(hero_dr_weird)
-        team_preventers.heroes.append(hero_cap)
-        session.add(team_preventers)
-        session.commit()
-        session.refresh(hero_tarantula)
-        session.refresh(hero_dr_weird)
-        session.refresh(hero_cap)
-        print("Preventers new hero:", hero_tarantula)
-        print("Preventers new hero:", hero_dr_weird)
-        print("Preventers new hero:", hero_cap)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py b/docs_src/tutorial/relationship_attributes/define_relationship_attributes/tutorial001.py
deleted file mode 100644 (file)
index af218b9..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py b/docs_src/tutorial/relationship_attributes/read_relationships/tutorial001.py
deleted file mode 100644 (file)
index b8bbe70..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-        hero_tarantula = Hero(name="Tarantula", secret_name="Natalia Roman-on", age=32)
-        hero_dr_weird = Hero(name="Dr. Weird", secret_name="Steve Weird", age=36)
-        hero_cap = Hero(
-            name="Captain North America", secret_name="Esteban Rogelios", age=93
-        )
-
-        team_preventers.heroes.append(hero_tarantula)
-        team_preventers.heroes.append(hero_dr_weird)
-        team_preventers.heroes.append(hero_cap)
-        session.add(team_preventers)
-        session.commit()
-        session.refresh(hero_tarantula)
-        session.refresh(hero_dr_weird)
-        session.refresh(hero_cap)
-        print("Preventers new hero:", hero_tarantula)
-        print("Preventers new hero:", hero_dr_weird)
-        print("Preventers new hero:", hero_cap)
-
-
-def select_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Spider-Boy")
-        result = session.exec(statement)
-        hero_spider_boy = result.one()
-
-        statement = select(Team).where(Team.id == hero_spider_boy.team_id)
-        result = session.exec(statement)
-        team = result.first()
-        print("Spider-Boy's team:", team)
-
-        print("Spider-Boy's team again:", hero_spider_boy.team)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    select_heroes()
-
-
-if __name__ == "__main__":
-    main()
diff --git a/docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py b/docs_src/tutorial/relationship_attributes/read_relationships/tutorial002.py
deleted file mode 100644 (file)
index 30fa840..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-from typing import List, Optional
-
-from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select
-
-
-class Team(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    headquarters: str
-
-    heroes: List["Hero"] = Relationship(back_populates="team")
-
-
-class Hero(SQLModel, table=True):
-    id: Optional[int] = Field(default=None, primary_key=True)
-    name: str = Field(index=True)
-    secret_name: str
-    age: Optional[int] = Field(default=None, index=True)
-
-    team_id: Optional[int] = Field(default=None, foreign_key="team.id")
-    team: Optional[Team] = Relationship(back_populates="heroes")
-
-
-sqlite_file_name = "database.db"
-sqlite_url = f"sqlite:///{sqlite_file_name}"
-
-engine = create_engine(sqlite_url, echo=True)
-
-
-def create_db_and_tables():
-    SQLModel.metadata.create_all(engine)
-
-
-def create_heroes():
-    with Session(engine) as session:
-        team_preventers = Team(name="Preventers", headquarters="Sharp Tower")
-        team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar")
-
-        hero_deadpond = Hero(
-            name="Deadpond", secret_name="Dive Wilson", team=team_z_force
-        )
-        hero_rusty_man = Hero(
-            name="Rusty-Man", secret_name="Tommy Sharp", age=48, team=team_preventers
-        )
-        hero_spider_boy = Hero(name="Spider-Boy", secret_name="Pedro Parqueador")
-        session.add(hero_deadpond)
-        session.add(hero_rusty_man)
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_deadpond)
-        session.refresh(hero_rusty_man)
-        session.refresh(hero_spider_boy)
-
-        print("Created hero:", hero_deadpond)
-        print("Created hero:", hero_rusty_man)
-        print("Created hero:", hero_spider_boy)
-
-        hero_spider_boy.team = team_preventers
-        session.add(hero_spider_boy)
-        session.commit()
-        session.refresh(hero_spider_boy)
-        print("Updated hero:", hero_spider_boy)
-
-        hero_black_lion = Hero(name="Black Lion", secret_name="Trevor Challa", age=35)
-        hero_sure_e = Hero(name="Princess Sure-E", secret_name="Sure-E")
-        team_wakaland = Team(
-            name="Wakaland",
-            headquarters="Wakaland Capital City",
-            heroes=[hero_black_lion, hero_sure_e],
-        )
-        session.add(team_wakaland)
-        session.commit()
-        session.refresh(team_wakaland)
-        print("Team Wakaland:", team_wakaland)
-
-        hero_tarantula = Hero(name="Tarantula", secret_name="Natalia Roman-on", age=32)
-        hero_dr_weird = Hero(name="Dr. Weird", secret_name="Steve Weird", age=36)
-        hero_cap = Hero(
-            name="Captain North America", secret_name="Esteban Rogelios", age=93
-        )
-
-        team_preventers.heroes.append(hero_tarantula)
-        team_preventers.heroes.append(hero_dr_weird)
-        team_preventers.heroes.append(hero_cap)
-        session.add(team_preventers)
-        session.commit()
-        session.refresh(hero_tarantula)
-        session.refresh(hero_dr_weird)
-        session.refresh(hero_cap)
-        print("Preventers new hero:", hero_tarantula)
-        print("Preventers new hero:", hero_dr_weird)
-        print("Preventers new hero:", hero_cap)
-
-
-def select_heroes():
-    with Session(engine) as session:
-        statement = select(Team).where(Team.name == "Preventers")
-        result = session.exec(statement)
-        team_preventers = result.one()
-
-        print("Preventers heroes:", team_preventers.heroes)
-
-
-def update_heroes():
-    with Session(engine) as session:
-        statement = select(Hero).where(Hero.name == "Spider-Boy")
-        result = session.exec(statement)
-        hero_spider_boy = result.one()
-
-        hero_spider_boy.team = None
-        session.add(hero_spider_boy)
-        session.commit()
-
-        session.refresh(hero_spider_boy)
-        print("Spider-Boy without team:", hero_spider_boy)
-
-
-def main():
-    create_db_and_tables()
-    create_heroes()
-    select_heroes()
-    update_heroes()
-
-
-if __name__ == "__main__":
-    main()
index 936791db50165c5d0ed29b6c3d4628494debe2b2..378eaca66978608966cc2fe1580582471d439044 100644 (file)
@@ -2,15 +2,11 @@
 -r requirements-docs-tests.txt
 pytest >=7.0.1,<9.0.0
 coverage[toml] >=6.2,<8.0
-# Remove when support for Python 3.8 is dropped
-mypy ==1.14.1; python_version < "3.9"
-mypy ==1.19.1; python_version >= "3.9"
+mypy ==1.19.1
 ruff ==0.14.10
 # For FastAPI tests
 fastapi >=0.103.2,<0.126.0
 httpx ==0.28.1
 dirty-equals ==0.9.0
 jinja2 ==3.1.6
-# Remove when support for Python 3.8 is dropped
-typing-extensions ==4.13.2; python_version < "3.9"
-typing-extensions ==4.15.0; python_version >= "3.9"
+typing-extensions ==4.15.0
index 98a4d2b7e621a002441265217cef4a67cf15d409..d8da629db0b83d510f43de2331faf6655ddab0ad 100644 (file)
@@ -31,7 +31,7 @@ def clear_sqlmodel() -> Any:
 def cov_tmp_path(tmp_path: Path) -> Generator[Path, None, None]:
     yield tmp_path
     for coverage_path in tmp_path.glob(".coverage*"):
-        coverage_destiny_path = top_level_path / coverage_path.name
+        coverage_destiny_path = top_level_path / "coverage" / coverage_path.name
         shutil.copy(coverage_path, coverage_destiny_path)
 
 
@@ -89,7 +89,6 @@ def print_mock_fixture() -> Generator[PrintMock, None, None]:
 needs_pydanticv2 = pytest.mark.skipif(not IS_PYDANTIC_V2, reason="requires Pydantic v2")
 needs_pydanticv1 = pytest.mark.skipif(IS_PYDANTIC_V2, reason="requires Pydantic v1")
 
-needs_py39 = pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9+")
 needs_py310 = pytest.mark.skipif(
     sys.version_info < (3, 10), reason="requires python3.10+"
 )
index dad8f24c4c4376bdeae58587d467fb0aa02e6ade..2e839e0e2624c16811dc66aa44d028653947f204 100644 (file)
@@ -11,7 +11,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index ab4f3387dc1b01d9439dcc43a37852d72d2a792c..e453ef00e2f05208f6dc7c1dd673a6cbd80af5ac 100644 (file)
@@ -11,7 +11,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index b1ff5ba3fdfea7b69280876f819597304430d0a1..e171c1e0ea5ca48a9707940e4a20a830b1bfdeed 100644 (file)
@@ -11,7 +11,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 664cebf2a7978d9aa54f24301493816278236851..94ed340e94ab61547810b7d096f8f9030bf1ff33 100644 (file)
@@ -3,12 +3,9 @@ import subprocess
 import sys
 from pathlib import Path
 
-from .conftest import needs_py39
-
 root_path = Path(__file__).parent.parent
 
 
-@needs_py39
 def test_select_gen() -> None:
     env = os.environ.copy()
     env["CHECK_JINJA"] = "1"
index 7233e40be8fe340a82dde5f05c65d8bb40b2e7eb..b2c452f907efeb47e55fe8844626a4371fcc9bb7 100644 (file)
@@ -138,8 +138,8 @@ def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]) -> None:
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        "tutorial002",
+        "tutorial001_py39",
+        "tutorial002_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
index 99ae5c00f0641168cc6bbcc5742ba57d22eacf66..aa832f6223e1601cb71abe2461793fa9e32d08d8 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from tests.conftest import PrintMock, needs_py39, needs_py310
+from tests.conftest import PrintMock, needs_py310
 
 expected_calls = [
     [
@@ -34,8 +34,7 @@ class Modules:
 @pytest.fixture(
     name="modules",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index f1d4043e8517655b962b3a4dbb9fde1f8b6dd2be..990d3ecaaaa582722199c44c5eac8133b4080afc 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ...conftest import PrintMock, needs_py39, needs_py310
+from ...conftest import PrintMock, needs_py310
 
 expected_calls = [
     [
@@ -34,8 +34,7 @@ class Modules:
 @pytest.fixture(
     name="modules",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 49d4acfa0072b9447044c9d478d010f48662efe2..66e57debeb399705fcdf350635c4ea5453246be8 100644 (file)
@@ -12,7 +12,7 @@ from tests.conftest import needs_py310
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index cc25dd42e36d52fa735f5ea74d1045747fc23e0b..7e20767f59265296b37f6572e17ee694a3e79e22 100644 (file)
@@ -63,7 +63,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 6c4ec3ab1cdfbb2f3080e246a95251c0afcc4633..c7363a0731875f73f48044832d8e5c8b421922a1 100644 (file)
@@ -43,7 +43,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 6553bc1ae633cda8a496d2b112fed05f5c4e13a6..4b141f11d1ecc3ad60d3cdaf2662880240eedcbf 100644 (file)
@@ -77,7 +77,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -90,7 +90,7 @@ def test_tutorial001(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial002",
+        "tutorial002_py39",
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
     indirect=True,
index 6036b672a33f538d6817777a6d067575a2900c14..3ded56065cd62585f73e44eac2e79dc280d7aa77 100644 (file)
@@ -79,7 +79,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial003",
+        "tutorial003_py39",
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index c9fa695eda399d1a7119c8ea9414e5af8db5e1ad..7e8240bb09f52dfe109ebb88a0545b69ab8001a5 100644 (file)
@@ -53,7 +53,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial004",
+        "tutorial004_py39",
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
 )
index 12d98b7e6634103271ce5d82613f4453799c3773..004229a29bb1a7a1d2cba53f5d729f8768f01b13 100644 (file)
@@ -55,7 +55,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial005",
+        "tutorial005_py39",
         pytest.param("tutorial005_py310", marks=needs_py310),
     ],
 )
index aa94c912160c35fac18703ad03fa4be0ff994c44..7120dce7edc8d5bec054511ecc286e1c4eaaf964 100644 (file)
@@ -53,7 +53,7 @@ expected_calls = [
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 4aeeb64b6c9ed7c7a9651a682be3c197b8c24eb6..3e054bf3ebe9ae8710d7e54d9f44bab096ab3b27 100644 (file)
@@ -8,7 +8,7 @@ from ...conftest import coverage_run, needs_py310
 @pytest.mark.parametrize(
     "module_name",
     [
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 0f1ad85fe9f33a9b2bc6c17dca37502d009967e5..f92bfee71dfc46ba328a27840fd46efa4620641b 100644 (file)
@@ -12,7 +12,7 @@ from ...conftest import needs_py310
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial002",
+        "tutorial002_py39",
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 446feae71a7201da7956b20cd9c5afd29d3c7455..e11e0a047243ef971fcc695fb8b5819e8133029e 100644 (file)
@@ -12,7 +12,7 @@ from ...conftest import needs_py310
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial003",
+        "tutorial003_py39",
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 3d755ae02777616160a9c55eaf0ac684210b32f9..5e6c354b3e4d3604d5c35a68b4cfb78ed4a3d1f0 100644 (file)
@@ -71,7 +71,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial001",
+        "tutorial001_py39",
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -84,7 +84,7 @@ def test_tutorial001(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial002",
+        "tutorial002_py39",
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
     indirect=True,
index 95be986fc9f9d1677e215752a9832d072fe03620..71fc72318f82ea70722ed498483299be020dddeb 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 
 import pytest
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @dataclass
@@ -17,8 +17,7 @@ class Modules:
 @pytest.fixture(
     name="modules_path",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 1f360c6f12ad150af6d13df0807b3fe0d91f41b5..73bf080ec7b984e5fbb79b2b9c9833825a3c5d3c 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 
 import pytest
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @dataclass
@@ -17,8 +17,7 @@ class Modules:
 @pytest.fixture(
     name="modules_path",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
@@ -35,7 +34,7 @@ def load_modules(clear_sqlmodel, modules_path: str) -> Modules:
         app_mod = sys.modules[app_mod_path]
         importlib.reload(app_mod)
     else:
-        app_mod = importlib.import_module(app_mod_path)
+        app_mod = importlib.import_module(app_mod_path)  # pragma: no cover
     test_mod = importlib.import_module(f"{modules_path}.test_main_002")
     return Modules(app=app_mod, test=test_mod)
 
index 4911173b62ca54dd2701f377265d25df49205478..41c4d5730127b3bffe5aab13ffd181ca9bc1c22a 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 
 import pytest
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @dataclass
@@ -17,8 +17,7 @@ class Modules:
 @pytest.fixture(
     name="modules_path",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
@@ -35,7 +34,7 @@ def load_modules(clear_sqlmodel, modules_path: str) -> Modules:
         app_mod = sys.modules[app_mod_path]
         importlib.reload(app_mod)
     else:
-        app_mod = importlib.import_module(app_mod_path)
+        app_mod = importlib.import_module(app_mod_path)  # pragma: no cover
     test_mod = importlib.import_module(f"{modules_path}.test_main_003")
     return Modules(app=app_mod, test=test_mod)
 
index b3ca441d24a234947ff4c8f4e199489b2e24fdaf..ba3a61ad1f43c7988c801b25f8b255168bf0ac32 100644 (file)
@@ -5,7 +5,7 @@ from types import ModuleType
 
 import pytest
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @dataclass
@@ -17,8 +17,7 @@ class Modules:
 @pytest.fixture(
     name="modules_path",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
@@ -35,7 +34,7 @@ def load_modules(clear_sqlmodel, modules_path: str) -> Modules:
         app_mod = sys.modules[app_mod_path]
         importlib.reload(app_mod)
     else:
-        app_mod = importlib.import_module(app_mod_path)
+        app_mod = importlib.import_module(app_mod_path)  # pragma: no cover
     test_mod = importlib.import_module(f"{modules_path}.test_main_004")
     return Modules(app=app_mod, test=test_mod)
 
index cc550c400821bbd03003318075f5af6f02813ba2..5d704ffb5740270e1974b9dd034d0503f198b5df 100644 (file)
@@ -3,9 +3,11 @@ import importlib
 import pytest
 from sqlmodel import Session
 
-from docs_src.tutorial.fastapi.app_testing.tutorial001 import main as app_mod
-from docs_src.tutorial.fastapi.app_testing.tutorial001 import test_main_005 as test_mod
-from docs_src.tutorial.fastapi.app_testing.tutorial001.test_main_005 import (
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39 import main as app_mod
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39 import (
+    test_main_005 as test_mod,
+)
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39.test_main_005 import (
     session_fixture,
 )
 
index 67c9ac6ad40f9b0246505593cc8d137edf628f48..1d474a7ec85ae7240d83719a6a26b869982d1710 100644 (file)
@@ -4,9 +4,11 @@ import pytest
 from fastapi.testclient import TestClient
 from sqlmodel import Session
 
-from docs_src.tutorial.fastapi.app_testing.tutorial001 import main as app_mod
-from docs_src.tutorial.fastapi.app_testing.tutorial001 import test_main_006 as test_mod
-from docs_src.tutorial.fastapi.app_testing.tutorial001.test_main_006 import (
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39 import main as app_mod
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39 import (
+    test_main_006 as test_mod,
+)
+from docs_src.tutorial.fastapi.app_testing.tutorial001_py39.test_main_006 import (
     client_fixture,
     session_fixture,
 )
index 28959f79d8acfdf0f4df406d970173c759a2aee1..c6d942ea3fbe84a92ae51aa586ab40f3af961fc0 100644 (file)
@@ -5,14 +5,13 @@ from types import ModuleType
 
 import pytest
 
-from ....conftest import needs_py39, needs_py310
+from ....conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 1480a06f54a5294678a2e2c9ec6d563011f864c1..ffbf7587f162370582b2ac1a97c05a9d9fd63663 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index dc3db8b5b0a0fda686da6272674873d9969aa106..cbc722c5c2ee2c50a903154ae56bdc096c2c5960 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 27629c891d6894bedd703d24cea8bd5d75b0e82b..d70dce32e6841353d8de303bf5344a232dcd4209 100644 (file)
@@ -9,14 +9,13 @@ from sqlalchemy.engine.reflection import Inspector
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index c840bde253ffeb9215d54f4768459a2aea68acba..8d7c8064e7208a041122f030e1e338af56206fc2 100644 (file)
@@ -9,14 +9,13 @@ from sqlalchemy.engine.reflection import Inspector
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index affea513ddcaef6e1f6acf5d652dde9d80c3a67b..7ebbecd8de4af93741edeaa89e4fcf0bc6b53a31 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 1d0446ed41687ddc97a42711b41e3b802c2fe98c..cf24466c138d9a0daac845e3e3200cbccdca4d50 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 186a12031188acf528cfccb433458492f275b88c..1ad004e93925f11b4595ed544b0422ed9fedc042 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 184fb219a9427bcda403236c5b0558268e8a7761..6e441cccbc1dac2166eacb86660a43b38258707b 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index dba7bc3879dc1035031f0977d327020673a01c22..b803cee28a61ad90084581851d78231627283da4 100644 (file)
@@ -13,7 +13,7 @@ from tests.conftest import needs_py310
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 2e7d66a036448ed6287e274afe8977766ee71a63..3b028b7d91625404925a6e8da5ea586e8ae66d89 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index b6ee27611f32d42d3d27580f7a8b5d1433f0cf80..9bc54fbcfb17f7734300c168ac7f2c5c4b0da597 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index a9312651b706fa07d23ecdd183512370586415bb..ede67fe4e4bc7e7c99d5b35347cb0c04a633db79 100644 (file)
@@ -7,14 +7,13 @@ from fastapi.testclient import TestClient
 from sqlmodel import Session, create_engine
 from sqlmodel.pool import StaticPool
 
-from tests.conftest import needs_py39, needs_py310
+from tests.conftest import needs_py310
 
 
 @pytest.fixture(
     name="module",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index b71f7ebd85125f2dd2192ab718cd7714ffd4c769..8f031a8a32ee5a01f2a335102ba50444f6ab1f85 100644 (file)
@@ -12,7 +12,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 0aa88ea5dd928f0d701a753b69894672581f0786..29b0987a40666cd9adfca46961f55d7c92259942 100644 (file)
@@ -12,7 +12,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 1673a7075396f80f34576b50d190b0b8023f9066..6e20feeb15472a8ca78aa850b3880ca62c3c72ff 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 0cee7ef3b132b8155bcc3610e27df3582b074be1..b70ac63739b228b8e07519598c5e214d7295fb22 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 7f80585875d43c3d1f7ef96c6815edf0821c7c29..902f5519d8ba9b17278c67c965faf95abdf82e6c 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index d33713cde36a38e2d36b6ccba2ccef67ee8f579b..b1b581e38e47c2ba1f14e0bbd1ad8d2d266bcc35 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index c73f701cd123309ec41dc709be4a0c992de39dbb..896f2bfcec33c2add67591a79d473a5546effb0a 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index a33cf49f063b482723f5dc7ab9285d0d5d2e9f45..8e9e0b730219ee0f6f7ffe6e926c08ef4c711946 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 15322c4089a18bb0298c45b7c49b752d86466330..228acd6aac47ccef164a1cf00486b19f6348de29 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial004",
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
 )
index b84626d9cff89090cb95e63c4a9091d7e64d7eaf..427fe418958fcb1ab660dd23b6b866409b288a34 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ...conftest import PrintMock, needs_py39, needs_py310
+from ...conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index b5562f416d5b2df5f4b4c14c0a752bb6fd0c7dc4..7ac120d5aef7d4fc1aa8bbe22605ff35a65fe3f6 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ...conftest import PrintMock, needs_py39, needs_py310
+from ...conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index ad1168e3baef32309103f9378afb215966a4ed90..6c14445b03e8efebcd01e1c589b7b8819fcee87d 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ...conftest import PrintMock, needs_py39, needs_py310
+from ...conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
-        pytest.param("tutorial003_py39", marks=needs_py39),
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 2f6f1c9e8916a53a1e458e44c1c75d57756cd579..a4dd986ba061f221d6028b1bd43d2b65dbb6c658 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 267ead8939f91f854ecb52365925e287e96ac4a5..96dda11d2f6785b3b00cfd4f1249243993b6c123 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index de2e529aea114c9d1c78ec1d72303ef779716c2e..5de20da9121119b1c6d623ceaf3ec4de979834d6 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 9df91fbb4177ccacae7be900ecdae3c0499423a0..fce8277189ab70e58103de8602f2373e9050f776 100644 (file)
@@ -11,7 +11,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial004",
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
 )
index fa569020a131b0c4cd837ff260a40790986ced75..a4f7914060921c5abc44b95fed257740de92aeda 100644 (file)
@@ -11,7 +11,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial005",
+        pytest.param("tutorial005_py39"),
         pytest.param("tutorial005_py310", marks=needs_py310),
     ],
 )
index 1c6c663dc502a9c1af344d7a3fa7edfcc7baabea..4ae19a5ee2ab7f8f71ea175d238f5c7734d52930 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial006",
+        pytest.param("tutorial006_py39"),
         pytest.param("tutorial006_py310", marks=needs_py310),
     ],
 )
index ca4a5310a56302b06e971d28c7e53c6da37938eb..edf674fef5a0651de0bf422915618f254085a0b3 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial007",
+        pytest.param("tutorial007_py39"),
         pytest.param("tutorial007_py310", marks=needs_py310),
     ],
 )
index da451fbaa2477a4958de32c007ce0fdf5e7deb4f..5a8e03a2d0b54248e082f55e72746a907c639c2e 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial008",
+        pytest.param("tutorial008_py39"),
         pytest.param("tutorial008_py310", marks=needs_py310),
     ],
 )
index 0cf3a6267fc5c5a7a97c3e9746be1efaee406b2d..bfd1d3a2c381b9b542ec786e7209b07b7da26dd7 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial009",
+        pytest.param("tutorial009_py39"),
         pytest.param("tutorial009_py310", marks=needs_py310),
     ],
 )
index 698a7af2cb5e4a9b5fc9d6ae261f44c02f010889..208cfb7caa95120d5a9b054a9b13aabfe1f41876 100644 (file)
@@ -5,14 +5,13 @@ import pytest
 from sqlalchemy.exc import SAWarning
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 8ce54be46c4b94c1907a07efc93afac072aca0bb..65a849f270365b1e3cb4e55f6171676e54e6c03f 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index d30c71c3c2d51a6ac2d70c31a2633812f696f5a0..a23800db9813a6ba628abf12e660ebcd15f848fe 100644 (file)
@@ -6,14 +6,13 @@ from sqlalchemy import inspect
 from sqlalchemy.engine.reflection import Inspector
 from sqlmodel import create_engine
 
-from ....conftest import needs_py39, needs_py310
+from ....conftest import needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
-        pytest.param("tutorial003_py39", marks=needs_py39),
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 0c6a229178e7b82c8ef684b119483ce840c40ab8..d73be8f3c3e10a8281fde0d26e381018efeee74d 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 96cf8bcc49808c2e24294d05da8568e4e141a739..516f3e384378887a8c625dd2fb2def7ab04badf5 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 5e43f80c4ce286a9b3b24b94432a27e8298e2b44..fddaf3d9bf6c2ffc02a65e8f93d0bd120b4dd1b7 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index cb3907afd7cc654b5661444ae147e1ecf7f5355e..5614c2fecc772c37e73d26ecd32d10682444250c 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index e063630f9638a2207d65c59210fc034840d72625..095062d7d7fb63c2aa1c67f805e35944798ba0d4 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
-        pytest.param("tutorial003_py39", marks=needs_py39),
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index 8b6c101fb8c9df7ea3af275ab0dead6577ea740f..fb045d45a72f3ffaa4c8936f5ee31cc0f750654d 100644 (file)
@@ -5,14 +5,13 @@ import pytest
 from sqlalchemy.exc import IntegrityError
 from sqlmodel import Session, create_engine, select
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial004",
-        pytest.param("tutorial004_py39", marks=needs_py39),
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
 )
index 273007770ba3645de18086688ccfd188a1ea83ec..d2170f225ccb7a36d98ba1f02e2889d2e6f5008d 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial005",
-        pytest.param("tutorial005_py39", marks=needs_py39),
+        pytest.param("tutorial005_py39"),
         pytest.param("tutorial005_py310", marks=needs_py310),
     ],
 )
index 1b2caaa9c52feb65e2aa0de6b2ebad3b70e6d308..651f44a0332f0b79178ddd0426e070205cfc3476 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
-        pytest.param("tutorial001_py39", marks=needs_py39),
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 68ee2cc1d8e5cb1982f3bfa2414f5e13bcf06921..306f3f174b1a55505be1eadb16c0854832bef960 100644 (file)
@@ -4,14 +4,13 @@ from types import ModuleType
 import pytest
 from sqlmodel import create_engine
 
-from ....conftest import PrintMock, needs_py39, needs_py310
+from ....conftest import PrintMock, needs_py310
 
 
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
-        pytest.param("tutorial002_py39", marks=needs_py39),
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index a3f5e90d46cccd475b82c52baf555f8da330dc74..3dc5c186c074e3f402e4b0597a50a4be2222949e 100644 (file)
@@ -40,7 +40,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -53,7 +53,7 @@ def test_tutorial_001(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
     indirect=True,
index 967ecdbd50d5d93ad5daa2432536b0f9b8adfe1d..e64d5f8b79b917a17b30b08f0aa23c9448863a7e 100644 (file)
@@ -42,7 +42,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -55,7 +55,7 @@ def test_tutorial_003(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial004",
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
     indirect=True,
index ef12a8d950ce098f762bbeb1630c2e320cfe04d0..6f4b05ee1d3f006a67c681ec2a7955498c187a5e 100644 (file)
@@ -39,7 +39,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -52,7 +52,7 @@ def test_tutorial001(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
     indirect=True,
index 76788c62cdf860763ebde4994afc45e22eaadf03..944b2ebf0631fecc6504badee841fc62283bd683 100644 (file)
@@ -52,7 +52,7 @@ def get_module(request: pytest.FixtureRequest) -> ModuleType:
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
     indirect=True,
@@ -65,7 +65,7 @@ def test_tutorial003(print_mock: PrintMock, module: ModuleType):
 @pytest.mark.parametrize(
     "module",
     [
-        "tutorial004",
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
     indirect=True,
index 1a557deefc01ee67a5f23319cc2a1919b31eb474..a6b869d81e978deb81466f7d3bb043c0d482f58b 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial001",
+        pytest.param("tutorial001_py39"),
         pytest.param("tutorial001_py310", marks=needs_py310),
     ],
 )
index 1c96f76126fa7863bcfc6a72a867d4494a0c1a66..7c6812fb2b3d42cc6245ee4c959988349d9b669b 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial002",
+        pytest.param("tutorial002_py39"),
         pytest.param("tutorial002_py310", marks=needs_py310),
     ],
 )
index 6e90d22fc4e6ff70e1603e4ec8c9b1087ae6f712..304310a77ae01833c85914332f28258899fd08ce 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial003",
+        pytest.param("tutorial003_py39"),
         pytest.param("tutorial003_py310", marks=needs_py310),
     ],
 )
index b7a1212b77f6a1742941a1359df662cec639ff34..bace062f67198224734d26acb84c346a63bcfc1b 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial004",
+        pytest.param("tutorial004_py39"),
         pytest.param("tutorial004_py310", marks=needs_py310),
     ],
 )
index 9adbec74a280f27f8a207cdfaed4dc2541dd83ed..39f7b1b2bcdaa670fd9cdc6675d215b6d7674964 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial005",
+        pytest.param("tutorial005_py39"),
         pytest.param("tutorial005_py310", marks=needs_py310),
     ],
 )
index e5d586a39aae55b85fabe47a7d024803bc513a84..9830142ad04657f574f748d82f8ee157101dfdaa 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial006",
+        pytest.param("tutorial006_py39"),
         pytest.param("tutorial006_py310", marks=needs_py310),
     ],
 )
index 9a36279d381f3b0b10e8597a6589def9bb30f94f..c2650193da7affc4d18826bfeb31863cb242ae6c 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial007",
+        pytest.param("tutorial007_py39"),
         pytest.param("tutorial007_py310", marks=needs_py310),
     ],
 )
index a21e2ecbe3e83a75ec3182eee2e900ade24309be..ac5ccf0553d4db59a588390fb0aae591da420901 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial008",
+        pytest.param("tutorial008_py39"),
         pytest.param("tutorial008_py310", marks=needs_py310),
     ],
 )
index 8088045b02ef15a8db3118ab8919fcd306dc5b58..22b359768ead460d9e537619ff7f5e4a80eaf1fb 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial009",
+        pytest.param("tutorial009_py39"),
         pytest.param("tutorial009_py310", marks=needs_py310),
     ],
 )
index ea235ef708e4500661666ffde6150576cf928986..8740de1a7c7d56e161c05392acbd7a17f45c3802 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial010",
+        pytest.param("tutorial010_py39"),
         pytest.param("tutorial010_py310", marks=needs_py310),
     ],
 )
index ba53550611f099902336505b6a99bbb10c23e999..8131e2adc1ea266c7e38fd518a6a3e669c78c1d9 100644 (file)
@@ -10,7 +10,7 @@ from ...conftest import PrintMock, needs_py310
 @pytest.fixture(
     name="mod",
     params=[
-        "tutorial011",
+        pytest.param("tutorial011_py39"),
         pytest.param("tutorial011_py310", marks=needs_py310),
     ],
 )