Compare commits
278 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1c2f822c9 | ||
|
|
382b1b0cbb | ||
|
|
6d00f6fcbd | ||
|
|
8ed856d322 | ||
|
|
77c6fed305 | ||
|
|
c0294423f4 | ||
|
|
e05eae6a49 | ||
|
|
ed22232dee | ||
|
|
dacc1fa9ca | ||
|
|
0b2d015fc4 | ||
|
|
d8a20d9c21 | ||
|
|
188f7cd172 | ||
|
|
12af94655b | ||
|
|
4bb99763b1 | ||
|
|
9dd11ef74f | ||
|
|
fa5d14e413 | ||
|
|
df1efcfa7f | ||
|
|
fc1d7afae9 | ||
|
|
a2d1b4eeaf | ||
|
|
94f3765fcf | ||
|
|
31ed654dd0 | ||
|
|
cbaf172c63 | ||
|
|
c557cf6d18 | ||
|
|
9632980664 | ||
|
|
6457775a0f | ||
|
|
717594ef13 | ||
|
|
e4e1385eed | ||
|
|
13cc722110 | ||
|
|
7fdfee10a5 | ||
|
|
8d14232538 | ||
|
|
99f8ce3894 | ||
|
|
d05c3ee495 | ||
|
|
596718d93b | ||
|
|
a6ce817ca5 | ||
|
|
dcc4e4c36a | ||
|
|
80fd7e03cf | ||
|
|
1acb683f80 | ||
|
|
9fd7306648 | ||
|
|
9d3ca01dd0 | ||
|
|
6cd086f25f | ||
|
|
376603efb2 | ||
|
|
30d2b30217 | ||
|
|
9b186c89a8 | ||
|
|
fc3120a877 | ||
|
|
6d361e3ffb | ||
|
|
03f295b397 | ||
|
|
403d44ea78 | ||
|
|
a1caaa08d7 | ||
|
|
d192142eb9 | ||
|
|
beb7a24275 | ||
|
|
dee70033b8 | ||
|
|
189059e07e | ||
|
|
475b838c8b | ||
|
|
d6e4f9b9e3 | ||
|
|
1062e1b485 | ||
|
|
8e55ea5125 | ||
|
|
9732c5ac60 | ||
|
|
b8996f0e62 | ||
|
|
9809b5bc83 | ||
|
|
c213f5daf4 | ||
|
|
d1cf613461 | ||
|
|
d281a0fa9f | ||
|
|
9511c4677d | ||
|
|
c25a8cb89b | ||
|
|
d3261cab59 | ||
|
|
40c1af9202 | ||
|
|
b83e848699 | ||
|
|
2676cf2b06 | ||
|
|
56f43904c1 | ||
|
|
7c5894ee75 | ||
|
|
27a81b2112 | ||
|
|
7f72c60ae4 | ||
|
|
065fcdc828 | ||
|
|
9ba3039106 | ||
|
|
840fd08ab2 | ||
|
|
a8a792e3c0 | ||
|
|
8970833b14 | ||
|
|
5231c8b6bb | ||
|
|
1568bad01e | ||
|
|
357417e6d5 | ||
|
|
893d64fd31 | ||
|
|
2799303f6c | ||
|
|
a2e2942aad | ||
|
|
b7d6a0a3c3 | ||
|
|
bdcf11bca6 | ||
|
|
d939b7c45c | ||
|
|
d5219aa3c5 | ||
|
|
aa7169b93b | ||
|
|
89c356cb77 | ||
|
|
088164ef2a | ||
|
|
1e2fd10047 | ||
|
|
30a9c23a34 | ||
|
|
da29f7940d | ||
|
|
40007c80da | ||
|
|
e246ae8864 | ||
|
|
aaa54492c1 | ||
|
|
73fa81af74 | ||
|
|
a21d5c85a3 | ||
|
|
02bd7ebffd | ||
|
|
43a689d369 | ||
|
|
810236c26c | ||
|
|
33e00c3ab3 | ||
|
|
5c9a3b3b21 | ||
|
|
dc44d2e2c4 | ||
|
|
1c294ddeb6 | ||
|
|
c47a54df91 | ||
|
|
624a2142bf | ||
|
|
7b3148c0b4 | ||
|
|
cf36b2d9ba | ||
|
|
5fa9062ed9 | ||
|
|
267cd42fb6 | ||
|
|
497270dc55 | ||
|
|
aa87ff37ea | ||
|
|
0fe1e6d5a3 | ||
|
|
54b5db9842 | ||
|
|
c31bac638c | ||
|
|
203db14e9b | ||
|
|
06bb369bcb | ||
|
|
209791734c | ||
|
|
fbc6f3b536 | ||
|
|
22faa192b9 | ||
|
|
3a9244c69f | ||
|
|
8070b142b8 | ||
|
|
f0aa199611 | ||
|
|
5956940908 | ||
|
|
ea79c47c0e | ||
|
|
7e26dac198 | ||
|
|
bb32178bda | ||
|
|
5ca9375f26 | ||
|
|
e7d8b69b53 | ||
|
|
c6ad5b8109 | ||
|
|
8003c73877 | ||
|
|
b532a4c304 | ||
|
|
29d9721d1a | ||
|
|
f0f6f93e28 | ||
|
|
91d8e38208 | ||
|
|
ccdab8fb24 | ||
|
|
592c877cfc | ||
|
|
fee7ecf619 | ||
|
|
e8f61fb9d0 | ||
|
|
781174e6e9 | ||
|
|
ba76745f43 | ||
|
|
5615a80fc5 | ||
|
|
375e83d068 | ||
|
|
666a9a3557 | ||
|
|
1dde3e0044 | ||
|
|
8b87bf8b40 | ||
|
|
94715b6fa8 | ||
|
|
27a16744f2 | ||
|
|
75ce45588b | ||
|
|
b3e1a66a21 | ||
|
|
c94db7b8a0 | ||
|
|
a67326d358 | ||
|
|
e88b5d3691 | ||
|
|
fdb049bee3 | ||
|
|
ae144e0a39 | ||
|
|
85f5e7fc45 | ||
|
|
b51ebaf658 | ||
|
|
f232166db5 | ||
|
|
4143edd251 | ||
|
|
f9522b3913 | ||
|
|
e7848923ec | ||
|
|
eb12bbc640 | ||
|
|
6216409f96 | ||
|
|
6fe256ec2c | ||
|
|
92f52a3fc5 | ||
|
|
2bc915ed04 | ||
|
|
42b0e6eace | ||
|
|
1ca288028c | ||
|
|
a2cda8377f | ||
|
|
8ac82e7101 | ||
|
|
5429e9b6aa | ||
|
|
c743647a52 | ||
|
|
475578757f | ||
|
|
5e0ac5b56c | ||
|
|
d380736043 | ||
|
|
71d6fcc31b | ||
|
|
680602b7eb | ||
|
|
9c68ce12ec | ||
|
|
eef0b7770b | ||
|
|
2fab4817fe | ||
|
|
5ea9340def | ||
|
|
db3ad598c5 | ||
|
|
9830ee0d89 | ||
|
|
2407ecd2bf | ||
|
|
ee576ab279 | ||
|
|
ae1b8b5585 | ||
|
|
e48fb2874b | ||
|
|
7d3bf70a76 | ||
|
|
91d0785b1c | ||
|
|
5dfef7ede7 | ||
|
|
0aaf39d539 | ||
|
|
c0a6b2dd8b | ||
|
|
87a02b4c46 | ||
|
|
14fc1f510e | ||
|
|
ad0766fe3e | ||
|
|
1e69c00538 | ||
|
|
bf15380733 | ||
|
|
a993c2141d | ||
|
|
deed65095f | ||
|
|
61294af824 | ||
|
|
106fb1fe9b | ||
|
|
6b433a0de4 | ||
|
|
4de5a41720 | ||
|
|
dc5876c727 | ||
|
|
5f6b5bfd7f | ||
|
|
e5fdc371f6 | ||
|
|
452f18d8bc | ||
|
|
04b8b3eedf | ||
|
|
426da7c443 | ||
|
|
a5116a372c | ||
|
|
015f7acbc5 | ||
|
|
34e125357f | ||
|
|
c0efc7b370 | ||
|
|
48ada0cd5d | ||
|
|
aa5803fbbb | ||
|
|
8bee55e23b | ||
|
|
6f1ffccd4f | ||
|
|
13544c0f44 | ||
|
|
184c8eb5a9 | ||
|
|
acc27dabc9 | ||
|
|
d032c3cfea | ||
|
|
006cf488e8 | ||
|
|
63dd44dc86 | ||
|
|
f602794f07 | ||
|
|
f3063a8e16 | ||
|
|
f67a13a5fb | ||
|
|
5dff4d15e8 | ||
|
|
943892ddb2 | ||
|
|
31beaf1017 | ||
|
|
9664c8814c | ||
|
|
7bb99f2bd5 | ||
|
|
4a08ee89ee | ||
|
|
0197c6e211 | ||
|
|
6da8dcfc8e | ||
|
|
dc4dc42ec5 | ||
|
|
db29f53295 | ||
|
|
bc6dc0bafc | ||
|
|
36b0c1ba08 | ||
|
|
dc0ecbb2c2 | ||
|
|
aca18da21e | ||
|
|
f7d1bbe5b6 | ||
|
|
296a0935d1 | ||
|
|
0049436cd4 | ||
|
|
f4500c6ba4 | ||
|
|
c830c71e28 | ||
|
|
ea18162391 | ||
|
|
4dd7b890d4 | ||
|
|
4d20051793 | ||
|
|
88683f6e2c | ||
|
|
d6229b3937 | ||
|
|
e523e1e4c3 | ||
|
|
6d969c5845 | ||
|
|
b94d393924 | ||
|
|
e009ecb704 | ||
|
|
03e861d048 | ||
|
|
8e97c93de0 | ||
|
|
7176d89e48 | ||
|
|
e6f8c00bbe | ||
|
|
c873aa3930 | ||
|
|
800a5f232f | ||
|
|
8d1b6f079a | ||
|
|
7fcd4fd7c5 | ||
|
|
9203df6af1 | ||
|
|
d6d77a9ee4 | ||
|
|
155c6178cd | ||
|
|
3d7b74746c | ||
|
|
410d7af6b6 | ||
|
|
1b99c3148f | ||
|
|
6cf94a9797 | ||
|
|
a159f31945 | ||
|
|
dc3acda4ed | ||
|
|
ead1bdc532 | ||
|
|
2013c69c4d | ||
|
|
6615b111d9 | ||
|
|
50e62cdcd9 | ||
|
|
64d7f53357 | ||
|
|
32b5b39f2d |
@@ -1,5 +1,3 @@
|
||||
name: Question or Problem
|
||||
description: Ask a question or ask about a problem
|
||||
labels: [question]
|
||||
body:
|
||||
- type: markdown
|
||||
@@ -8,29 +6,29 @@ body:
|
||||
Thanks for your interest in SQLModel! 🚀
|
||||
|
||||
Please follow these instructions, fill every question, and do every step. 🙏
|
||||
|
||||
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
|
||||
|
||||
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
|
||||
|
||||
I'm asking this because answering questions and solving problems in GitHub is what consumes most of the time.
|
||||
|
||||
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling questions.
|
||||
|
||||
All that, on top of all the incredible help provided by a bunch of community members that give a lot of their time to come here and help others.
|
||||
|
||||
If more SQLModel users came to help others like them just a little bit more, it would be much less effort for them (and you and me 😅).
|
||||
|
||||
By asking questions in a structured way (following this) it will be much easier to help you.
|
||||
|
||||
|
||||
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
|
||||
|
||||
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
|
||||
As there are too many questions, I'll have to discard and close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: First Check
|
||||
description: Please confirm and check all the following options.
|
||||
options:
|
||||
- label: I added a very descriptive title to this issue.
|
||||
- label: I added a very descriptive title here.
|
||||
required: true
|
||||
- label: I used the GitHub search to find a similar issue and didn't find it.
|
||||
- label: I used the GitHub search to find a similar question and didn't find it.
|
||||
required: true
|
||||
- label: I searched the SQLModel documentation, with the integrated search.
|
||||
required: true
|
||||
@@ -48,10 +46,10 @@ body:
|
||||
label: Commit to Help
|
||||
description: |
|
||||
After submitting this, I commit to one of:
|
||||
|
||||
|
||||
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
|
||||
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
|
||||
* Implement a Pull Request for a confirmed bug.
|
||||
* Review one Pull Request by downloading the code and following all the review process](https://sqlmodel.tiangolo.com/help/#review-pull-requests).
|
||||
|
||||
options:
|
||||
- label: I commit to help with one of those options 👆
|
||||
9
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -2,3 +2,12 @@ blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Security Contact
|
||||
about: Please report security vulnerabilities to security@tiangolo.com
|
||||
- name: Question or Problem
|
||||
about: Ask a question or ask about a problem in GitHub Discussions.
|
||||
url: https://github.com/tiangolo/sqlmodel/discussions/categories/questions
|
||||
- name: Feature Request
|
||||
about: To suggest an idea or ask about a feature, please start with a question saying what you would like to achieve. There might be a way to do it already.
|
||||
url: https://github.com/tiangolo/sqlmodel/discussions/categories/questions
|
||||
- name: Show and tell
|
||||
about: Show what you built with SQLModel or to be used with SQLModel.
|
||||
url: https://github.com/tiangolo/sqlmodel/discussions/categories/show-and-tell
|
||||
|
||||
214
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,214 +0,0 @@
|
||||
name: Feature Request
|
||||
description: Suggest an idea or ask for a feature that you would like to have in SQLModel
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for your interest in SQLModel! 🚀
|
||||
|
||||
Please follow these instructions, fill every question, and do every step. 🙏
|
||||
|
||||
I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time.
|
||||
|
||||
I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues.
|
||||
|
||||
All that, on top of all the incredible help provided by a bunch of community members that give a lot of their time to come here and help others.
|
||||
|
||||
If more SQLModel users came to help others like them just a little bit more, it would be much less effort for them (and you and me 😅).
|
||||
|
||||
By asking questions in a structured way (following this) it will be much easier to help you.
|
||||
|
||||
And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. 😎
|
||||
|
||||
As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. 🤓
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: First Check
|
||||
description: Please confirm and check all the following options.
|
||||
options:
|
||||
- label: I added a very descriptive title to this issue.
|
||||
required: true
|
||||
- label: I used the GitHub search to find a similar issue and didn't find it.
|
||||
required: true
|
||||
- label: I searched the SQLModel documentation, with the integrated search.
|
||||
required: true
|
||||
- label: I already searched in Google "How to X in SQLModel" and didn't find any information.
|
||||
required: true
|
||||
- label: I already read and followed all the tutorial in the docs and didn't find an answer.
|
||||
required: true
|
||||
- label: I already checked if it is not related to SQLModel but to [Pydantic](https://github.com/samuelcolvin/pydantic).
|
||||
required: true
|
||||
- label: I already checked if it is not related to SQLModel but to [SQLAlchemy](https://github.com/sqlalchemy/sqlalchemy).
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: help
|
||||
attributes:
|
||||
label: Commit to Help
|
||||
description: |
|
||||
After submitting this, I commit to one of:
|
||||
|
||||
* Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
|
||||
* I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
|
||||
* Implement a Pull Request for a confirmed bug.
|
||||
|
||||
options:
|
||||
- label: I commit to help with one of those options 👆
|
||||
required: true
|
||||
- type: textarea
|
||||
id: example
|
||||
attributes:
|
||||
label: Example Code
|
||||
description: |
|
||||
Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case.
|
||||
|
||||
If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you.
|
||||
|
||||
placeholder: |
|
||||
from typing import Optional
|
||||
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine
|
||||
|
||||
|
||||
class Hero(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
secret_name: str
|
||||
age: Optional[int] = None
|
||||
|
||||
|
||||
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
|
||||
|
||||
engine = create_engine("sqlite:///database.db")
|
||||
|
||||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
with Session(engine) as session:
|
||||
session.add(hero_1)
|
||||
session.commit()
|
||||
session.refresh(hero_1)
|
||||
print(hero_1)
|
||||
render: python
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: |
|
||||
What is your feature request?
|
||||
|
||||
Write a short description telling me what you are trying to solve and what you are currently doing.
|
||||
placeholder: |
|
||||
* Create a Hero model.
|
||||
* Create a Hero instance.
|
||||
* Save it to a SQLite database.
|
||||
* I would like it to also automatically send me an email with all the SQL code executed.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: wanted-solution
|
||||
attributes:
|
||||
label: Wanted Solution
|
||||
description: |
|
||||
Tell me what's the solution you would like.
|
||||
placeholder: |
|
||||
I would like it to have a `send_email` configuration that defaults to `False`, and can be set to `True` to send me an email.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: wanted-code
|
||||
attributes:
|
||||
label: Wanted Code
|
||||
description: Show me an example of how you would want the code to look like.
|
||||
placeholder: |
|
||||
from typing import Optional
|
||||
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine
|
||||
|
||||
|
||||
class Hero(SQLModel, table=True, send_email=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
secret_name: str
|
||||
age: Optional[int] = None
|
||||
|
||||
|
||||
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
|
||||
|
||||
engine = create_engine("sqlite:///database.db")
|
||||
|
||||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
with Session(engine) as session:
|
||||
session.add(hero_1)
|
||||
session.commit()
|
||||
session.refresh(hero_1)
|
||||
print(hero_1)
|
||||
|
||||
|
||||
render: python
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: |
|
||||
Tell me about alternatives you've considered.
|
||||
placeholder: |
|
||||
To hire someone to look at the logs, write the SQL in paper, and then send me a letter by post with it.
|
||||
- type: dropdown
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating System
|
||||
description: What operating system are you on?
|
||||
multiple: true
|
||||
options:
|
||||
- Linux
|
||||
- Windows
|
||||
- macOS
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: os-details
|
||||
attributes:
|
||||
label: Operating System Details
|
||||
description: You can add more details about your operating system here, in particular if you chose "Other".
|
||||
- type: input
|
||||
id: sqlmodel-version
|
||||
attributes:
|
||||
label: SQLModel Version
|
||||
description: |
|
||||
What SQLModel version are you using?
|
||||
|
||||
You can find the SQLModel version with:
|
||||
|
||||
```bash
|
||||
python -c "import sqlmodel; print(sqlmodel.__version__)"
|
||||
```
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: python-version
|
||||
attributes:
|
||||
label: Python Version
|
||||
description: |
|
||||
What Python version are you using?
|
||||
|
||||
You can find the Python version with:
|
||||
|
||||
```bash
|
||||
python --version
|
||||
```
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional Context
|
||||
description: Add any additional context information or screenshots you think are useful.
|
||||
22
.github/ISSUE_TEMPLATE/privileged.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Privileged
|
||||
description: You are @tiangolo or he asked you directly to create an issue here. If not, check the other options. 👇
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for your interest in SQLModel! 🚀
|
||||
|
||||
If you are not @tiangolo or he didn't ask you directly to create an issue here, please start the conversation in a [Question in GitHub Discussions](https://github.com/tiangolo/sqlmodel/discussions/categories/questions) instead.
|
||||
- type: checkboxes
|
||||
id: privileged
|
||||
attributes:
|
||||
label: Privileged issue
|
||||
description: Confirm that you are allowed to create an issue here.
|
||||
options:
|
||||
- label: I'm @tiangolo or he asked me directly to create an issue here.
|
||||
required: true
|
||||
- type: textarea
|
||||
id: content
|
||||
attributes:
|
||||
label: Issue Content
|
||||
description: Add the content of the issue here.
|
||||
@@ -48,9 +48,7 @@ if __name__ == "__main__":
|
||||
use_pr = pr
|
||||
break
|
||||
if not use_pr:
|
||||
logging.error(
|
||||
f"No PR found for hash: {event.workflow_run.head_commit.id}"
|
||||
)
|
||||
logging.error(f"No PR found for hash: {event.workflow_run.head_commit.id}")
|
||||
sys.exit(0)
|
||||
github_headers = {
|
||||
"Authorization": f"token {settings.input_token.get_secret_value()}"
|
||||
|
||||
7
.github/actions/watch-previews/Dockerfile
vendored
@@ -1,7 +0,0 @@
|
||||
FROM python:3.7
|
||||
|
||||
RUN pip install httpx PyGithub "pydantic==1.5.1"
|
||||
|
||||
COPY ./app /app
|
||||
|
||||
CMD ["python", "/app/main.py"]
|
||||
10
.github/actions/watch-previews/action.yml
vendored
@@ -1,10 +0,0 @@
|
||||
name: Watch docs previews in PRs
|
||||
description: Check PRs and trigger new docs deploys
|
||||
author: "Sebastián Ramírez <tiangolo@gmail.com>"
|
||||
inputs:
|
||||
token:
|
||||
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}'
|
||||
required: true
|
||||
runs:
|
||||
using: docker
|
||||
image: Dockerfile
|
||||
102
.github/actions/watch-previews/app/main.py
vendored
@@ -1,102 +0,0 @@
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
|
||||
import httpx
|
||||
from github import Github
|
||||
from github.NamedUser import NamedUser
|
||||
from pydantic import BaseModel, BaseSettings, SecretStr
|
||||
|
||||
github_api = "https://api.github.com"
|
||||
netlify_api = "https://api.netlify.com"
|
||||
main_branch = "main"
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
input_token: SecretStr
|
||||
github_repository: str
|
||||
github_event_path: Path
|
||||
github_event_name: Optional[str] = None
|
||||
|
||||
|
||||
class Artifact(BaseModel):
|
||||
id: int
|
||||
node_id: str
|
||||
name: str
|
||||
size_in_bytes: int
|
||||
url: str
|
||||
archive_download_url: str
|
||||
expired: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
class ArtifactResponse(BaseModel):
|
||||
total_count: int
|
||||
artifacts: List[Artifact]
|
||||
|
||||
|
||||
def get_message(commit: str) -> str:
|
||||
return f"Docs preview for commit {commit} at"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
settings = Settings()
|
||||
logging.info(f"Using config: {settings.json()}")
|
||||
g = Github(settings.input_token.get_secret_value())
|
||||
repo = g.get_repo(settings.github_repository)
|
||||
owner: NamedUser = repo.owner
|
||||
headers = {"Authorization": f"token {settings.input_token.get_secret_value()}"}
|
||||
prs = list(repo.get_pulls(state="open"))
|
||||
response = httpx.get(
|
||||
f"{github_api}/repos/{settings.github_repository}/actions/artifacts",
|
||||
headers=headers,
|
||||
)
|
||||
data = response.json()
|
||||
artifacts_response = ArtifactResponse.parse_obj(data)
|
||||
for pr in prs:
|
||||
logging.info("-----")
|
||||
logging.info(f"Processing PR #{pr.number}: {pr.title}")
|
||||
pr_comments = list(pr.get_issue_comments())
|
||||
pr_commits = list(pr.get_commits())
|
||||
last_commit = pr_commits[0]
|
||||
for pr_commit in pr_commits:
|
||||
if pr_commit.commit.author.date > last_commit.commit.author.date:
|
||||
last_commit = pr_commit
|
||||
commit = last_commit.commit.sha
|
||||
logging.info(f"Last commit: {commit}")
|
||||
message = get_message(commit)
|
||||
notified = False
|
||||
for pr_comment in pr_comments:
|
||||
if message in pr_comment.body:
|
||||
notified = True
|
||||
logging.info(f"Docs preview was notified: {notified}")
|
||||
if not notified:
|
||||
artifact_name = f"docs-zip-{commit}"
|
||||
use_artifact: Optional[Artifact] = None
|
||||
for artifact in artifacts_response.artifacts:
|
||||
if artifact.name == artifact_name:
|
||||
use_artifact = artifact
|
||||
break
|
||||
if not use_artifact:
|
||||
logging.info("Artifact not available")
|
||||
else:
|
||||
logging.info(f"Existing artifact: {use_artifact.name}")
|
||||
response = httpx.post(
|
||||
f"{github_api}/repos/{settings.github_repository}/actions/workflows/preview-docs.yml/dispatches",
|
||||
headers=headers,
|
||||
json={
|
||||
"ref": main_branch,
|
||||
"inputs": {
|
||||
"pr": f"{pr.number}",
|
||||
"name": artifact_name,
|
||||
"commit": commit,
|
||||
},
|
||||
},
|
||||
)
|
||||
logging.info(
|
||||
f"Trigger sent, response status: {response.status_code} - content: {response.content}"
|
||||
)
|
||||
logging.info("Finished")
|
||||
10
.github/dependabot.yml
vendored
@@ -1,6 +1,16 @@
|
||||
version: 2
|
||||
updates:
|
||||
# GitHub Actions
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
commit-message:
|
||||
prefix: ⬆
|
||||
# Python
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
commit-message:
|
||||
prefix: ⬆
|
||||
|
||||
105
.github/workflows/build-docs.yml
vendored
@@ -1,79 +1,94 @@
|
||||
name: Build Docs
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
# Required permissions
|
||||
permissions:
|
||||
pull-requests: read
|
||||
# Set job outputs to values from filter step
|
||||
outputs:
|
||||
docs: ${{ steps.filter.outputs.docs }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# For pull requests it's not necessary to checkout the code but for the main branch it is
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
docs:
|
||||
- README.md
|
||||
- docs/**
|
||||
- docs_src/**
|
||||
- pyproject.toml
|
||||
- mkdocs.yml
|
||||
- mkdocs.insiders.yml
|
||||
|
||||
build-docs:
|
||||
runs-on: ubuntu-20.04
|
||||
needs:
|
||||
- changes
|
||||
if: ${{ needs.changes.outputs.docs == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.7"
|
||||
# Allow debugging with tmate
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
- uses: actions/cache@v2
|
||||
python-version: "3.11"
|
||||
- uses: actions/cache@v3
|
||||
id: cache
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-docs
|
||||
- name: Install poetry
|
||||
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
|
||||
- name: Install Poetry
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
|
||||
# Ref: https://github.com/python-poetry/poetry-core/pull/188
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
python -m pip install "poetry==1.2.0a2"
|
||||
python -m poetry plugin add poetry-version-plugin
|
||||
python -m pip install "poetry"
|
||||
python -m poetry self add poetry-version-plugin
|
||||
- name: Configure poetry
|
||||
run: python -m poetry config virtualenvs.create false
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: python -m poetry install
|
||||
- name: Install Material for MkDocs Insiders
|
||||
if: github.event.pull_request.head.repo.fork == false && steps.cache.outputs.cache-hit != 'true'
|
||||
run: python -m poetry run pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
|
||||
- uses: actions/cache@v2
|
||||
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' ) && steps.cache.outputs.cache-hit != 'true'
|
||||
run: python -m poetry run pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: mkdocs-cards-${{ github.ref }}
|
||||
path: .cache
|
||||
- name: Build Docs
|
||||
if: github.event.pull_request.head.repo.fork == true
|
||||
if: github.event_name == 'pull_request' && github.secret_source != 'Actions'
|
||||
run: python -m poetry run mkdocs build
|
||||
- name: Build Docs with Insiders
|
||||
if: github.event.pull_request.head.repo.fork == false
|
||||
if: github.event_name != 'pull_request' || github.secret_source == 'Actions'
|
||||
run: python -m poetry run mkdocs build --config-file mkdocs.insiders.yml
|
||||
- name: Zip docs
|
||||
run: python -m poetry run bash ./scripts/zip-docs.sh
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: docs-zip
|
||||
path: ./docs.zip
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@v1.1.5
|
||||
name: docs-site
|
||||
path: ./site/**
|
||||
|
||||
# https://github.com/marketplace/actions/alls-green#why
|
||||
docs-all-green: # This job does nothing and is only used for the branch protection
|
||||
if: always()
|
||||
needs:
|
||||
- build-docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@release/v1
|
||||
with:
|
||||
publish-dir: './site'
|
||||
production-branch: main
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
enable-commit-comment: false
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
allowed-skips: build-docs
|
||||
|
||||
48
.github/workflows/deploy-docs.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
name: Deploy Docs
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- Build Docs
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
deploy-docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@v4
|
||||
- name: Clean site
|
||||
run: |
|
||||
rm -rf ./site
|
||||
mkdir ./site
|
||||
- name: Download Artifact Docs
|
||||
id: download
|
||||
uses: dawidd6/action-download-artifact@v2.28.0
|
||||
with:
|
||||
if_no_artifact_found: ignore
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: build-docs.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: docs-site
|
||||
path: ./site/
|
||||
- name: Deploy to Cloudflare Pages
|
||||
if: steps.download.outputs.found_artifact == 'true'
|
||||
id: deploy
|
||||
uses: cloudflare/pages-action@v1
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
projectName: sqlmodel
|
||||
directory: './site'
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'main' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
|
||||
- name: Comment Deploy
|
||||
if: steps.deploy.outputs.url != ''
|
||||
uses: ./.github/actions/comment-docs-preview-in-pr
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
deploy_url: "${{ steps.deploy.outputs.url }}"
|
||||
17
.github/workflows/latest-changes.yml
vendored
@@ -12,27 +12,30 @@ on:
|
||||
description: PR number
|
||||
required: true
|
||||
debug_enabled:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
default: 'false'
|
||||
|
||||
jobs:
|
||||
latest-changes:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
# To allow latest-changes to commit to the main branch
|
||||
token: ${{ secrets.ACTIONS_TOKEN }}
|
||||
token: ${{ secrets.SQLMODEL_LATEST_CHANGES }}
|
||||
# Allow debugging with tmate
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
- uses: docker://tiangolo/latest-changes:0.0.3
|
||||
- uses: docker://tiangolo/latest-changes:0.2.0
|
||||
# - uses: tiangolo/latest-changes@main
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
latest_changes_file: docs/release-notes.md
|
||||
latest_changes_header: '## Latest Changes\n\n'
|
||||
latest_changes_header: '## Latest Changes'
|
||||
end_regex: '^## '
|
||||
debug_logs: true
|
||||
label_header_prefix: '### '
|
||||
|
||||
41
.github/workflows/preview-docs.yml
vendored
@@ -1,41 +0,0 @@
|
||||
name: Preview Docs
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- Build Docs
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
preview-docs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download Artifact Docs
|
||||
uses: dawidd6/action-download-artifact@v2.9.0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
workflow: build-docs.yml
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: docs-zip
|
||||
- name: Unzip docs
|
||||
run: |
|
||||
rm -rf ./site
|
||||
unzip docs.zip
|
||||
rm -f docs.zip
|
||||
- name: Deploy to Netlify
|
||||
id: netlify
|
||||
uses: nwtgck/actions-netlify@v1.1.5
|
||||
with:
|
||||
publish-dir: './site'
|
||||
production-deploy: false
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
enable-commit-comment: false
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
||||
- name: Comment Deploy
|
||||
uses: ./.github/actions/comment-docs-preview-in-pr
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
deploy_url: "${{ steps.netlify.outputs.deploy-url }}"
|
||||
24
.github/workflows/publish.yml
vendored
@@ -7,40 +7,36 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
default: 'false'
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.7"
|
||||
# Allow debugging with tmate
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v3
|
||||
id: cache
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
|
||||
- name: Install poetry
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
|
||||
# Ref: https://github.com/python-poetry/poetry-core/pull/188
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
python -m pip install "poetry==1.2.0a2"
|
||||
python -m poetry plugin add poetry-version-plugin
|
||||
python -m pip install "poetry"
|
||||
python -m poetry self add poetry-version-plugin
|
||||
- name: Configure poetry
|
||||
run: python -m poetry config virtualenvs.create false
|
||||
- name: Install Dependencies
|
||||
|
||||
35
.github/workflows/smokeshow.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Smokeshow
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Test]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
statuses: write
|
||||
|
||||
jobs:
|
||||
smokeshow:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- run: pip install smokeshow
|
||||
|
||||
- uses: dawidd6/action-download-artifact@v2.28.0
|
||||
with:
|
||||
workflow: test.yml
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
|
||||
- run: smokeshow upload coverage-html
|
||||
env:
|
||||
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
|
||||
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 95
|
||||
SMOKESHOW_GITHUB_CONTEXT: coverage
|
||||
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}
|
||||
92
.github/workflows/test.yml
vendored
@@ -2,59 +2,113 @@ name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
debug_enabled:
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
||||
required: false
|
||||
default: false
|
||||
default: 'false'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.6, 3.7, 3.8, 3.9]
|
||||
python-version:
|
||||
- "3.7"
|
||||
- "3.8"
|
||||
- "3.9"
|
||||
- "3.10"
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
# Allow debugging with tmate
|
||||
- name: Setup tmate session
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
|
||||
with:
|
||||
limit-access-to-actor: true
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v3
|
||||
id: cache
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-v2
|
||||
- name: Install poetry
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
# TODO: remove python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
# once there's a release of Poetry 1.2.x including poetry-core > 1.1.0a6
|
||||
# Ref: https://github.com/python-poetry/poetry-core/pull/188
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2
|
||||
python -m pip install "poetry==1.2.0a2"
|
||||
python -m poetry plugin add poetry-version-plugin
|
||||
python -m pip install "poetry"
|
||||
python -m poetry self add poetry-version-plugin
|
||||
- name: Configure poetry
|
||||
run: python -m poetry config virtualenvs.create false
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: python -m poetry install
|
||||
- name: Lint
|
||||
if: ${{ matrix.python-version != '3.6' }}
|
||||
# Do not run on Python 3.7 as mypy behaves differently
|
||||
if: matrix.python-version != '3.7'
|
||||
run: python -m poetry run bash scripts/lint.sh
|
||||
- run: mkdir coverage
|
||||
- name: Test
|
||||
run: python -m poetry run bash scripts/test.sh
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
env:
|
||||
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
|
||||
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
|
||||
- name: Store coverage files
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
coverage-combine:
|
||||
needs:
|
||||
- test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8'
|
||||
|
||||
- name: Get coverage files
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
|
||||
- run: pip install coverage[toml]
|
||||
|
||||
- run: ls -la coverage
|
||||
- run: coverage combine coverage
|
||||
- run: coverage report
|
||||
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
|
||||
|
||||
- name: Store coverage HTML
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-html
|
||||
path: htmlcov
|
||||
|
||||
# https://github.com/marketplace/actions/alls-green#why
|
||||
alls-green: # This job does nothing and is only used for the branch protection
|
||||
if: always()
|
||||
needs:
|
||||
- coverage-combine
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@release/v1
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
|
||||
25
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
args:
|
||||
- --unsafe
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.4
|
||||
hooks:
|
||||
- id: ruff
|
||||
args:
|
||||
- --fix
|
||||
- id: ruff-format
|
||||
ci:
|
||||
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
|
||||
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
|
||||
24
CITATION.cff
Normal file
@@ -0,0 +1,24 @@
|
||||
# This CITATION.cff file was generated with cffinit.
|
||||
# Visit https://bit.ly/cffinit to generate yours today!
|
||||
|
||||
cff-version: 1.2.0
|
||||
title: SQLModel
|
||||
message: >-
|
||||
If you use this software, please cite it using the
|
||||
metadata from this file.
|
||||
type: software
|
||||
authors:
|
||||
- given-names: Sebastián
|
||||
family-names: Ramírez
|
||||
email: tiangolo@gmail.com
|
||||
identifiers:
|
||||
repository-code: 'https://github.com/tiangolo/sqlmodel'
|
||||
url: 'https://sqlmodel.tiangolo.com'
|
||||
abstract: >-
|
||||
SQLModel, SQL databases in Python, designed for
|
||||
simplicity, compatibility, and robustness.
|
||||
keywords:
|
||||
- fastapi
|
||||
- pydantic
|
||||
- sqlalchemy
|
||||
license: MIT
|
||||
@@ -11,9 +11,8 @@
|
||||
<a href="https://github.com/tiangolo/sqlmodel/actions?query=workflow%3APublish" target="_blank">
|
||||
<img src="https://github.com/tiangolo/sqlmodel/workflows/Publish/badge.svg" alt="Publish">
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/tiangolo/sqlmodel" target="_blank">
|
||||
<img src="https://img.shields.io/codecov/c/github/tiangolo/sqlmodel?color=%2334D058" alt="Coverage">
|
||||
</a>
|
||||
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/sqlmodel" target="_blank">
|
||||
<img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/sqlmodel.svg" alt="Coverage">
|
||||
<a href="https://pypi.org/project/sqlmodel" target="_blank">
|
||||
<img src="https://img.shields.io/pypi/v/sqlmodel?color=%2334D058&label=pypi%20package" alt="Package version">
|
||||
</a>
|
||||
@@ -51,7 +50,7 @@ It combines SQLAlchemy and Pydantic and tries to simplify the code you write as
|
||||
|
||||
## Requirements
|
||||
|
||||
A recent and currently supported version of Python (right now, <a href="https://www.python.org/downloads/" class="external-link" target="_blank">Python supports versions 3.6 and above</a>).
|
||||
A recent and currently supported <a href="https://www.python.org/downloads/" class="external-link" target="_blank">version of Python</a>.
|
||||
|
||||
As **SQLModel** is based on **Pydantic** and **SQLAlchemy**, it requires them. They will be automatically installed when you install SQLModel.
|
||||
|
||||
@@ -212,4 +211,4 @@ And at the same time, ✨ it is also a **Pydantic** model ✨. You can use inher
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the terms of the MIT license.
|
||||
This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/sqlmodel/blob/main/LICENSE).
|
||||
|
||||
@@ -6,10 +6,6 @@ First, you might want to see the basic ways to [help SQLModel and get help](help
|
||||
|
||||
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
|
||||
|
||||
### Python
|
||||
|
||||
SQLModel supports Python 3.6 and above, but for development you should have at least **Python 3.7**.
|
||||
|
||||
### Poetry
|
||||
|
||||
**SQLModel** uses <a href="https://python-poetry.org/" class="external-link" target="_blank">Poetry</a> to build, package, and publish the project.
|
||||
@@ -42,7 +38,7 @@ $ poetry shell
|
||||
|
||||
</div>
|
||||
|
||||
That will set up the environment variables needed dand will start a new shell with them.
|
||||
That will set up the environment variables needed and start a new shell with them.
|
||||
|
||||
#### Using your local SQLModel
|
||||
|
||||
@@ -116,7 +112,7 @@ There is a script that you can run locally to test all the code and generate cov
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ bash scripts/test-cov-html.sh
|
||||
$ bash scripts/test.sh
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
@@ -85,7 +85,7 @@ Some examples of databases that work like this could be **PostgreSQL**, **MySQL*
|
||||
|
||||
### Distributed servers
|
||||
|
||||
In some cases, the database could even be a group server applications running on different machines, working together and communicating between them to be more efficient and handle more data.
|
||||
In some cases, the database could even be a group of server applications running on different machines, working together and communicating between them to be more efficient and handle more data.
|
||||
|
||||
In this case, your code would talk to one or more of these server applications running on different machines.
|
||||
|
||||
@@ -250,7 +250,7 @@ As these **primary key** IDs can uniquely identify each row on the table for tea
|
||||
|
||||
<img alt="table relationships" src="/img/databases/relationships.svg">
|
||||
|
||||
So, in the table for heroes, we use the `team_id` column to define a relationship to the *foreign* table for teams. Each value in the `team_id` column on the table with heroes will be the same value as the `id` column of one row in the table wiwth teams.
|
||||
So, in the table for heroes, we use the `team_id` column to define a relationship to the *foreign* table for teams. Each value in the `team_id` column on the table with heroes will be the same value as the `id` column of one row in the table with teams.
|
||||
|
||||
In the table for heroes we have a **primary key** that is the `id`. But we also have another column `team_id` that refers to a **key** in a **foreign** table. There's a technical term for that too, the `team_id` is a "**foreign key**".
|
||||
|
||||
@@ -274,7 +274,7 @@ The language is called **SQL**, the name comes from for **Structured Query Langu
|
||||
|
||||
Nevertheless, the language is not only used to *query* for data. It is also used to create records/rows, to update them, to delete them. And to manipulate the database, create tables, etc.
|
||||
|
||||
This language is supported by all these databases that handle multiple tables, that's why they are called **SQL Databases**. Although, each database has small variations in the SQL language they support.
|
||||
This language is supported by all these databases that handle multiple tables, that's why they are called **SQL Databases**. Although, each database has small variations in the SQL language they support (*dialect*).
|
||||
|
||||
Let's imagine that the table holding the heroes is called the `hero` table. An example of a SQL query to get all the data from it could look like:
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ The user is probably, in some way, telling your application:
|
||||
2
|
||||
```
|
||||
|
||||
And the would be this table (with a single row):
|
||||
And the result would be this table (with a single row):
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -111,7 +111,7 @@ DROP TABLE hero;
|
||||
|
||||
That is how you tell the database in SQL to delete the entire table `hero`.
|
||||
|
||||
<a href="http://www.nooooooooooooooo.com/" class="external-link" target="_blank">Nooooo!</a> We lost all the data in the `hero` table! 💥😱
|
||||
<a href="https://theuselessweb.site/nooooooooooooooo/" class="external-link" target="_blank">Nooooo!</a> We lost all the data in the `hero` table! 💥😱
|
||||
|
||||
### SQL Sanitization
|
||||
|
||||
@@ -143,7 +143,7 @@ If the user provides this ID:
|
||||
2
|
||||
```
|
||||
|
||||
...the would be this table (with a single row):
|
||||
...the result would be this table (with a single row):
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -305,4 +305,4 @@ You will see **your own code** a lot more than the internal table names, so it's
|
||||
So, to keep things consistent, I'll keep using the same table names that **SQLModel** would have generated.
|
||||
|
||||
!!! tip
|
||||
You can also override the table name. You can read about it in the Advanced User Guide.
|
||||
You can also override the table name. You can read about it in the Advanced User Guide.
|
||||
|
||||
@@ -12,7 +12,7 @@ Nevertheless, SQLModel is completely **independent** of FastAPI and can be used
|
||||
|
||||
## Just Modern Python
|
||||
|
||||
It's all based on standard <abbr title="Python currently supported versions, 3.6 and above.">modern **Python**</abbr> type annotations. No new syntax to learn. Just standard modern Python.
|
||||
It's all based on standard <abbr title="Currently supported versions of Python">modern **Python**</abbr> type annotations. No new syntax to learn. Just standard modern Python.
|
||||
|
||||
If you need a 2 minute refresher of how to use Python types (even if you don't use SQLModel or FastAPI), check the FastAPI tutorial section: <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">Python types intro</a>.
|
||||
|
||||
|
||||
152
docs/help.md
@@ -12,7 +12,7 @@ And there are several ways to get help too.
|
||||
|
||||
## Subscribe to the FastAPI and Friends newsletter
|
||||
|
||||
You can subscribe to the (infrequent) [**FastAPI and friends** newsletter](/newsletter/){.internal-link target=_blank} to stay updated about:
|
||||
You can subscribe to the (infrequent) <a href="https://fastapi.tiangolo.com/newsletter" class="external-link" target="_blank">**FastAPI and friends** newsletter</a> to stay updated about:
|
||||
|
||||
* News about FastAPI and friends, including SQLModel 🚀
|
||||
* Guides 📝
|
||||
@@ -58,26 +58,125 @@ You can:
|
||||
|
||||
I love to hear about how **SQLModel** is being used, what you have liked in it, in which project/company are you using it, etc.
|
||||
|
||||
## Help others with issues in GitHub
|
||||
## Help others with questions in GitHub
|
||||
|
||||
You can see <a href="https://github.com/tiangolo/sqlmodel/issues" class="external-link" target="_blank">existing issues</a> and try and help others, most of the times they are questions that you might already know the answer for. 🤓
|
||||
You can try and help others with their questions in:
|
||||
|
||||
* <a href="https://github.com/tiangolo/sqlmodel/discussions/categories/questions?discussions_q=category%3AQuestions+is%3Aunanswered" class="external-link" target="_blank">GitHub Discussions</a>
|
||||
* <a href="https://github.com/tiangolo/sqlmodel/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Aquestion+-label%3Aanswered+" class="external-link" target="_blank">GitHub Issues</a>
|
||||
|
||||
In many cases you might already know the answer for those questions. 🤓
|
||||
|
||||
Just remember, the most important point is: try to be kind. People come with their frustrations and in many cases don't ask in the best way, but try as best as you can to be kind. 🤗
|
||||
|
||||
The idea is for the **SQLModel** community to be kind and welcoming. At the same time, don't accept bullying or disrespectful behavior towards others. We have to take care of each other.
|
||||
|
||||
---
|
||||
|
||||
Here's how to help others with questions (in discussions or issues):
|
||||
|
||||
### Understand the question
|
||||
|
||||
* Check if you can understand what is the **purpose** and use case of the person asking.
|
||||
|
||||
* Then check if the question (the vast majority are questions) is **clear**.
|
||||
|
||||
* In many cases the question asked is about an imaginary solution from the user, but there might be a **better** one. If you can understand the problem and use case better, you might be able to suggest a better **alternative solution**.
|
||||
|
||||
* If you can't understand the question, ask for more **details**.
|
||||
|
||||
### Reproduce the problem
|
||||
|
||||
For most of the cases and most of the questions there's something related to the person's **original code**.
|
||||
|
||||
In many cases they will only copy a fragment of the code, but that's not enough to **reproduce the problem**.
|
||||
|
||||
* You can ask them to provide a <a href="https://stackoverflow.com/help/minimal-reproducible-example" class="external-link" target="_blank">minimal, reproducible, example</a>, that you can **copy-paste** and run locally to see the same error or behavior they are seeing, or to understand their use case better.
|
||||
|
||||
* If you are feeling too generous, you can try to **create an example** like that yourself, just based on the description of the problem. Just have in mind that this might take a lot of time and it might be better to ask them to clarify the problem first.
|
||||
|
||||
### Suggest solutions
|
||||
|
||||
* After being able to understand the question, you can give them a possible **answer**.
|
||||
|
||||
* In many cases, it's better to understand their **underlying problem or use case**, because there might be a better way to solve it than what they are trying to do.
|
||||
|
||||
### Ask to close
|
||||
|
||||
If they reply, there's a high chance you would have solved their problem, congrats, **you're a hero**! 🦸
|
||||
|
||||
* Now, if that solved their problem, you can ask them to:
|
||||
|
||||
* In GitHub Discussions: mark the comment as the **answer**.
|
||||
* In GitHub Issues: **close** the issue**.
|
||||
|
||||
## Watch the GitHub repository
|
||||
|
||||
You can "watch" SQLModel in GitHub (clicking the "watch" button at the top right): <a href="https://github.com/tiangolo/sqlmodel" class="external-link" target="_blank">https://github.com/tiangolo/sqlmodel</a>. 👀
|
||||
|
||||
If you select "Watching" instead of "Releases only" you will receive notifications when someone creates a new issue.
|
||||
If you select "Watching" instead of "Releases only" you will receive notifications when someone creates a new issue or question. You can also specify that you only want to be notified about new issues, or discussions, or PRs, etc.
|
||||
|
||||
Then you can try and help them solve those issues.
|
||||
Then you can try and help them solve those questions.
|
||||
|
||||
## Create issues
|
||||
## Ask Questions
|
||||
|
||||
You can <a href="https://github.com/tiangolo/sqlmodel/issues/new/choose" class="external-link" target="_blank">create a new issue</a> in the GitHub repository, for example to:
|
||||
You can <a href="https://github.com/tiangolo/sqlmodel/discussions/new?category=questions" class="external-link" target="_blank">create a new question</a> in the GitHub repository, for example to:
|
||||
|
||||
* Ask a **question** or ask about a **problem**.
|
||||
* Suggest a new **feature**.
|
||||
|
||||
**Note**: if you create an issue, then I'm going to ask you to also help others. 😉
|
||||
**Note**: if you do it, then I'm going to ask you to also help others. 😉
|
||||
|
||||
## Review Pull Requests
|
||||
|
||||
You can help me review pull requests from others.
|
||||
|
||||
Again, please try your best to be kind. 🤗
|
||||
|
||||
---
|
||||
|
||||
Here's what to have in mind and how to review a pull request:
|
||||
|
||||
### Understand the problem
|
||||
|
||||
* First, make sure you **understand the problem** that the pull request is trying to solve. It might have a longer discussion in a GitHub Discussion or issue.
|
||||
|
||||
* There's also a good chance that the pull request is not actually needed because the problem can be solved in a **different way**. Then you can suggest or ask about that.
|
||||
|
||||
### Don't worry about style
|
||||
|
||||
* Don't worry too much about things like commit message styles, I will squash and merge customizing the commit manually.
|
||||
|
||||
* Also don't worry about style rules, there are already automatized tools checking that.
|
||||
|
||||
And if there's any other style or consistency need, I'll ask directly for that, or I'll add commits on top with the needed changes.
|
||||
|
||||
### Check the code
|
||||
|
||||
* Check and read the code, see if it makes sense, **run it locally** and see if it actually solves the problem.
|
||||
|
||||
* Then **comment** saying that you did that, that's how I will know you really checked it.
|
||||
|
||||
!!! info
|
||||
Unfortunately, I can't simply trust PRs that just have several approvals.
|
||||
|
||||
Several times it has happened that there are PRs with 3, 5 or more approvals, probably because the description is appealing, but when I check the PRs, they are actually broken, have a bug, or don't solve the problem they claim to solve. 😅
|
||||
|
||||
So, it's really important that you actually read and run the code, and let me know in the comments that you did. 🤓
|
||||
|
||||
* If the PR can be simplified in a way, you can ask for that, but there's no need to be too picky, there might be a lot of subjective points of view (and I will have my own as well 🙈), so it's better if you can focus on the fundamental things.
|
||||
|
||||
### Tests
|
||||
|
||||
* Help me check that the PR has **tests**.
|
||||
|
||||
* Check that the tests **fail** before the PR. 🚨
|
||||
|
||||
* Then check that the tests **pass** after the PR. ✅
|
||||
|
||||
* Many PRs don't have tests, you can **remind** them to add tests, or you can even **suggest** some tests yourself. That's one of the things that consume most time and you can help a lot with that.
|
||||
|
||||
* Then also comment what you tried, that way I'll know that you checked it. 🤓
|
||||
|
||||
## Create a Pull Request
|
||||
|
||||
@@ -86,7 +185,44 @@ You can [contribute](contributing.md){.internal-link target=_blank} to the sourc
|
||||
* To fix a typo you found on the documentation.
|
||||
* To propose new documentation sections.
|
||||
* To fix an existing issue/bug.
|
||||
* Make sure to add tests.
|
||||
* To add a new feature.
|
||||
* Make sure to add tests.
|
||||
* Make sure to add documentation if it's relevant.
|
||||
|
||||
## Help Maintain SQLModel
|
||||
|
||||
Help me maintain **SQLModel**! 🤓
|
||||
|
||||
There's a lot of work to do, and for most of it, **YOU** can do it.
|
||||
|
||||
The main tasks that you can do right now are:
|
||||
|
||||
* [Help others with questions in GitHub](#help-others-with-questions-in-github){.internal-link target=_blank} (see the section above).
|
||||
* [Review Pull Requests](#review-pull-requests){.internal-link target=_blank} (see the section above).
|
||||
|
||||
Those two tasks are what **consume time the most**. That's the main work of maintaining SQLModel.
|
||||
|
||||
If you can help me with that, **you are helping me maintain SQLModel** and making sure it keeps **advancing faster and better**. 🚀
|
||||
|
||||
## Join the chat
|
||||
|
||||
Join the 👥 <a href="https://discord.gg/VQjSZaeJmf" class="external-link" target="_blank">FastAPI and Friends Discord chat server</a> 👥 and hang out with others in the community. There's a `#sqlmodel` channel.
|
||||
|
||||
!!! tip
|
||||
For questions, ask them in <a href="https://github.com/tiangolo/sqlmodel/discussions/new?category=questions" class="external-link" target="_blank">GitHub Discussions</a>, there's a much better chance you will receive help there.
|
||||
|
||||
Use the chat only for other general conversations.
|
||||
|
||||
### Don't use the chat for questions
|
||||
|
||||
Have in mind that as chats allow more "free conversation", it's easy to ask questions that are too general and more difficult to answer, so, you might not receive answers.
|
||||
|
||||
In GitHub, the template will guide you to write the right question so that you can more easily get a good answer, or even solve the problem yourself even before asking. And in GitHub I can make sure I always answer everything, even if it takes some time. I can't personally do that with the chat. 😅
|
||||
|
||||
Conversations in the chat are also not as easily searchable as in GitHub, so questions and answers might get lost in the conversation.
|
||||
|
||||
On the other side, there are thousands of users in the chat, so there's a high chance you'll find someone to talk to there, almost all the time. 😄
|
||||
|
||||
## Sponsor the author
|
||||
|
||||
|
||||
@@ -90,4 +90,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -202,4 +202,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
@@ -148,4 +148,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
@@ -81,4 +81,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -34,4 +34,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
@@ -61,4 +61,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
97
docs/img/tutorial/indexes/dictionary001.drawio
Normal file
@@ -0,0 +1,97 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1463" dy="1403" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" vertex="1" parent="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="68" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" vertex="1" parent="1">
|
||||
<mxGeometry x="580" y="1030" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
57
docs/img/tutorial/indexes/dictionary001.svg
Normal file
|
After Width: | Height: | Size: 30 KiB |
97
docs/img/tutorial/indexes/dictionary002.drawio
Normal file
@@ -0,0 +1,97 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1707" dy="1637" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeWidth=3;strokeColor=#b85450;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="68" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1030" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary002.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
97
docs/img/tutorial/indexes/dictionary003.drawio
Normal file
@@ -0,0 +1,97 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1205" dy="1155" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeWidth=3;strokeColor=#b85450;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
|
||||
<mxGeometry x="580" y="1030" width="560" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary003.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
100
docs/img/tutorial/indexes/dictionary004.drawio
Normal file
@@ -0,0 +1,100 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1463" dy="1403" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="68" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="1030" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="1030" width="560" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary004.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
97
docs/img/tutorial/indexes/dictionary005.drawio
Normal file
@@ -0,0 +1,97 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1024" dy="982" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeWidth=3;strokeColor=#b85450;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="1030" width="840" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary005.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
100
docs/img/tutorial/indexes/dictionary006.drawio
Normal file
@@ -0,0 +1,100 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1024" dy="982" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="1030" width="840" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="70" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" vertex="1" parent="1">
|
||||
<mxGeometry x="180" y="1030" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary006.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
100
docs/img/tutorial/indexes/dictionary007.drawio
Normal file
@@ -0,0 +1,100 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1024" dy="982" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeWidth=3;strokeColor=#b85450;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="1030" width="840" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="71" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
|
||||
<mxGeometry x="100" y="1030" width="120" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary007.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
103
docs/img/tutorial/indexes/dictionary008.drawio
Normal file
@@ -0,0 +1,103 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1024" dy="982" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="950" width="1040" height="160" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="39" value="<font style="font-size: 24px">A</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="40" value="<font style="font-size: 24px">B</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="140" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="41" value="<font style="font-size: 24px">C</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeWidth=3;strokeColor=#82b366;" parent="1" vertex="1">
|
||||
<mxGeometry x="220" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="43" value="<font style="font-size: 24px">E</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="44" value="<font style="font-size: 24px">F</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="300" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="45" value="<font style="font-size: 24px">G</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="340" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="46" value="<font style="font-size: 24px">H</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="380" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="47" value="<font style="font-size: 24px">I</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="420" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="48" value="<font style="font-size: 24px">J</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="49" value="<font style="font-size: 24px">K</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="500" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="50" value="<font style="font-size: 24px">L</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="540" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="51" value="<font style="font-size: 24px">M</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="580" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="52" value="<font style="font-size: 24px">N</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="620" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="53" value="<font style="font-size: 24px">O</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="660" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="54" value="<font style="font-size: 24px">P</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="700" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="55" value="<font style="font-size: 24px">Q</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="740" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="56" value="<font style="font-size: 24px">R</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="780" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="57" value="<font style="font-size: 24px">S</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="820" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="58" value="<font style="font-size: 24px">T</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="860" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="59" value="<font style="font-size: 24px">U</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="900" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="60" value="<font style="font-size: 24px">V</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="940" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="61" value="<font style="font-size: 24px">W</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="980" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="62" value="<font style="font-size: 24px">X</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1020" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="63" value="<font style="font-size: 24px">Y</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1060" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="64" value="<font style="font-size: 24px">Z</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="1100" y="840" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Dictionary</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="565" y="960" width="110" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="69" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="1030" width="880" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="71" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeWidth=3;strokeColor=#666666;fontColor=#333333;" parent="1" vertex="1">
|
||||
<mxGeometry x="100" y="1030" width="120" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="72" value="<font style="font-size: 24px">D</font>" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#d5e8d4;strokeWidth=3;strokeColor=#82b366;" vertex="1" parent="1">
|
||||
<mxGeometry x="220" y="1030" width="40" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/dictionary008.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
92
docs/img/tutorial/indexes/techbook001.drawio
Normal file
@@ -0,0 +1,92 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="objTApYHlBqCKos3M7rL" name="Page-1">
|
||||
<mxGraphModel dx="1707" dy="1637" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1920" pageHeight="1200" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="4" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FFFFFF;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="80" y="420" width="1020" height="490" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="66" value="<font style="font-size: 24px">Technical Book</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="492.5" y="440" width="195" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="77" value="<font style="font-size: 24px">Chapter 1</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="100" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="83" value="<font style="font-size: 24px">Chapter 2</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="84" value="<font style="font-size: 24px">Chapter 3</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="380" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="85" value="<font style="font-size: 24px">Chapter 4</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="86" value="<font style="font-size: 24px">Chapter 5</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="660" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="87" value="<font style="font-size: 24px">Chapter 6</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="800" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="88" value="<font style="font-size: 24px">Chapter 7</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
|
||||
<mxGeometry x="940" y="490" width="140" height="90" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="74" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeWidth=3;strokeColor=#d6b656;" vertex="1" parent="1">
|
||||
<mxGeometry x="100" y="580" width="980" height="310" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="75" value="<font style="font-size: 24px">Book Index</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="498.125" y="840" width="183.75" height="30" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="89" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="42" target="77">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="92" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="42" target="86">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="42" value="<font style="font-size: 24px">Database</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" parent="1" vertex="1">
|
||||
<mxGeometry x="119.99615384615385" y="690" width="150.76923076923077" height="70" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="94" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="93" target="83">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="330" y="820"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="95" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="93" target="85">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="590" y="800"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="93" value="<font style="font-size: 24px">Python</font>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="909.9961538461539" y="780" width="150.76923076923077" height="70" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="97" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="96" target="87">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="98" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="96" target="86">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="770" y="725"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="96" value="<span style="font-size: 24px">Files</span>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="909.9961538461539" y="690" width="150.76923076923077" height="70" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="100" style="edgeStyle=orthogonalEdgeStyle;html=1;strokeWidth=3;" edge="1" parent="1" source="99" target="84">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="450" y="800"/>
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="99" value="<span style="font-size: 24px">Editors</span>" style="rounded=0;whiteSpace=wrap;html=1;strokeWidth=3;" vertex="1" parent="1">
|
||||
<mxGeometry x="119.9961538461539" y="780" width="150.76923076923077" height="70" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
1
docs/img/tutorial/indexes/techbook001.svg
Normal file
|
After Width: | Height: | Size: 17 KiB |
@@ -217,4 +217,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
@@ -130,4 +130,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -130,4 +130,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -130,4 +130,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -38,4 +38,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
@@ -49,4 +49,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
@@ -139,4 +139,4 @@
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
</mxfile>
|
||||
|
||||
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
@@ -11,9 +11,8 @@
|
||||
<a href="https://github.com/tiangolo/sqlmodel/actions?query=workflow%3APublish" target="_blank">
|
||||
<img src="https://github.com/tiangolo/sqlmodel/workflows/Publish/badge.svg" alt="Publish">
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/tiangolo/sqlmodel" target="_blank">
|
||||
<img src="https://img.shields.io/codecov/c/github/tiangolo/sqlmodel?color=%2334D058" alt="Coverage">
|
||||
</a>
|
||||
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/sqlmodel" target="_blank">
|
||||
<img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/sqlmodel.svg" alt="Coverage">
|
||||
<a href="https://pypi.org/project/sqlmodel" target="_blank">
|
||||
<img src="https://img.shields.io/pypi/v/sqlmodel?color=%2334D058&label=pypi%20package" alt="Package version">
|
||||
</a>
|
||||
@@ -51,7 +50,7 @@ It combines SQLAlchemy and Pydantic and tries to simplify the code you write as
|
||||
|
||||
## Requirements
|
||||
|
||||
A recent and currently supported version of Python (right now, <a href="https://www.python.org/downloads/" class="external-link" target="_blank">Python supports versions 3.6 and above</a>).
|
||||
A recent and currently supported <a href="https://www.python.org/downloads/" class="external-link" target="_blank">version of Python</a>.
|
||||
|
||||
As **SQLModel** is based on **Pydantic** and **SQLAlchemy**, it requires them. They will be automatically installed when you install SQLModel.
|
||||
|
||||
@@ -69,7 +68,7 @@ Successfully installed sqlmodel
|
||||
|
||||
## Example
|
||||
|
||||
For an introduction to databases, SQL, and everything else, see the <a href="https://sqlmodel.tiangolo.com" target="_blank">SQLModel documentation</a>.
|
||||
For an introduction to databases, SQL, and everything else, see the <a href="https://sqlmodel.tiangolo.com/databases/" target="_blank">SQLModel documentation</a>.
|
||||
|
||||
Here's a quick example. ✨
|
||||
|
||||
@@ -212,4 +211,4 @@ And at the same time, ✨ it is also a **Pydantic** model ✨. You can use inher
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the terms of the MIT license.
|
||||
This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/sqlmodel/blob/main/LICENSE).
|
||||
|
||||
@@ -72,14 +72,14 @@ class Termynal {
|
||||
* Initialise the widget, get lines, clear container and start animation.
|
||||
*/
|
||||
init() {
|
||||
/**
|
||||
/**
|
||||
* Calculates width and height of Termynal container.
|
||||
* If container is empty and lines are dynamically loaded, defaults to browser `auto` or CSS.
|
||||
*/
|
||||
*/
|
||||
const containerStyle = getComputedStyle(this.container);
|
||||
this.container.style.width = containerStyle.width !== '0px' ?
|
||||
this.container.style.width = containerStyle.width !== '0px' ?
|
||||
containerStyle.width : undefined;
|
||||
this.container.style.minHeight = containerStyle.height !== '0px' ?
|
||||
this.container.style.minHeight = containerStyle.height !== '0px' ?
|
||||
containerStyle.height : undefined;
|
||||
|
||||
this.container.setAttribute('data-termynal', '');
|
||||
@@ -138,7 +138,7 @@ class Termynal {
|
||||
restart.innerHTML = "restart ↻"
|
||||
return restart
|
||||
}
|
||||
|
||||
|
||||
generateFinish() {
|
||||
const finish = document.createElement('a')
|
||||
finish.onclick = (e) => {
|
||||
@@ -215,7 +215,7 @@ class Termynal {
|
||||
|
||||
/**
|
||||
* Converts line data objects into line elements.
|
||||
*
|
||||
*
|
||||
* @param {Object[]} lineData - Dynamically loaded lines.
|
||||
* @param {Object} line - Line data object.
|
||||
* @returns {Element[]} - Array of line elements.
|
||||
@@ -231,7 +231,7 @@ class Termynal {
|
||||
|
||||
/**
|
||||
* Helper function for generating attributes string.
|
||||
*
|
||||
*
|
||||
* @param {Object} line - Line data object.
|
||||
* @returns {string} - String of attributes.
|
||||
*/
|
||||
|
||||
31
docs/overrides/main.html
Normal file
@@ -0,0 +1,31 @@
|
||||
{% extends "base.html" %}
|
||||
{%- block scripts %}
|
||||
{{ super() }}
|
||||
<script src="https://cdn.jsdelivr.net/npm/qabot@0.4"></script>
|
||||
<script>
|
||||
// This prevents the global search from interfering with qa-bot's internal text input.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('qa-bot').forEach((x) => {
|
||||
x.addEventListener('keydown', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<qa-bot
|
||||
server="https://tiangolo-sqlmodel.docsqa.jina.ai"
|
||||
theme="infer"
|
||||
title="SQLModel Bot"
|
||||
description="SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness."
|
||||
style="font-size: 0.8rem"
|
||||
>
|
||||
<template>
|
||||
<dl>
|
||||
<dt>You can ask questions about SQLModel. Try:</dt>
|
||||
<dd>Which Python version is supported?</dd>
|
||||
<dd>How SQLModel interacts with the database?</dd>
|
||||
<dd>How can I link tables?</dd>
|
||||
</dl>
|
||||
</template>
|
||||
</qa-bot>
|
||||
{%- endblock %}
|
||||
@@ -2,6 +2,271 @@
|
||||
|
||||
## Latest Changes
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Upgrade SQLAlchemy to 2.0. PR [#700](https://github.com/tiangolo/sqlmodel/pull/700) by [@tiangolo](https://github.com/tiangolo) including initial work in PR [#563](https://github.com/tiangolo/sqlmodel/pull/563) by [@farahats9](https://github.com/farahats9).
|
||||
|
||||
### Internal
|
||||
|
||||
* ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#686](https://github.com/tiangolo/sqlmodel/pull/686) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
|
||||
* 👷 Upgrade latest-changes GitHub Action. PR [#693](https://github.com/tiangolo/sqlmodel/pull/693) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.0.11
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Add support for passing a custom SQLAlchemy type to `Field()` with `sa_type`. PR [#505](https://github.com/tiangolo/sqlmodel/pull/505) by [@maru0123-2004](https://github.com/maru0123-2004).
|
||||
* You might consider this a breaking change if you were using an incompatible combination of arguments, those arguments were not taking effect and now you will have a type error and runtime error telling you that.
|
||||
* ✨ Do not allow invalid combinations of field parameters for columns and relationships, `sa_column` excludes `sa_column_args`, `primary_key`, `nullable`, etc. PR [#681](https://github.com/tiangolo/sqlmodel/pull/681) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Docs
|
||||
|
||||
* 🎨 Update inline source examples, hide `#` in annotations (from MkDocs Material). PR [#677](https://github.com/tiangolo/sqlmodel/pull/677) by [@Matthieu-LAURENT39](https://github.com/Matthieu-LAURENT39).
|
||||
|
||||
### Internal
|
||||
|
||||
* ⬆ Update coverage requirement from ^6.2 to >=6.2,<8.0. PR [#663](https://github.com/tiangolo/sqlmodel/pull/663) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Update mkdocs-material requirement from 9.1.21 to 9.2.7. PR [#675](https://github.com/tiangolo/sqlmodel/pull/675) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆️ Upgrade mypy manually. PR [#684](https://github.com/tiangolo/sqlmodel/pull/684) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Update black requirement from ^22.10.0 to >=22.10,<24.0. PR [#664](https://github.com/tiangolo/sqlmodel/pull/664) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* 👷 Update CI to build MkDocs Insiders only when the secrets are available, for Dependabot. PR [#683](https://github.com/tiangolo/sqlmodel/pull/683) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Add support for all `Field` parameters from Pydantic `1.9.0` and above, make Pydantic `1.9.0` the minimum required version. PR [#440](https://github.com/tiangolo/sqlmodel/pull/440) by [@daniil-berg](https://github.com/daniil-berg).
|
||||
|
||||
### Internal
|
||||
|
||||
* 🔧 Adopt Ruff for formatting. PR [#679](https://github.com/tiangolo/sqlmodel/pull/679) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* 🗑️ Deprecate Python 3.6 and upgrade Poetry and Poetry Version Plugin. PR [#627](https://github.com/tiangolo/sqlmodel/pull/627) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Raise a more clear error when a type is not valid. PR [#425](https://github.com/tiangolo/sqlmodel/pull/425) by [@ddanier](https://github.com/ddanier).
|
||||
|
||||
### Fixes
|
||||
|
||||
* 🐛 Fix `AsyncSession` type annotations for `exec()`. PR [#58](https://github.com/tiangolo/sqlmodel/pull/58) by [@Bobronium](https://github.com/Bobronium).
|
||||
* 🐛 Fix allowing using a `ForeignKey` directly, remove repeated column construction from `SQLModelMetaclass.__init__` and upgrade minimum SQLAlchemy to `>=1.4.36`. PR [#443](https://github.com/tiangolo/sqlmodel/pull/443) by [@daniil-berg](https://github.com/daniil-berg).
|
||||
* 🐛 Fix enum type checks ordering in `get_sqlalchemy_type`. PR [#669](https://github.com/tiangolo/sqlmodel/pull/669) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🐛 Fix SQLAlchemy version 1.4.36 breaks SQLModel relationships (#315). PR [#461](https://github.com/tiangolo/sqlmodel/pull/461) by [@byrman](https://github.com/byrman).
|
||||
|
||||
### Upgrades
|
||||
|
||||
* ⬆️ Upgrade support for SQLAlchemy 1.4.49, update tests. PR [#519](https://github.com/tiangolo/sqlmodel/pull/519) by [@sandrotosi](https://github.com/sandrotosi).
|
||||
* ⬆ Raise SQLAlchemy version requirement to at least `1.4.29` (related to #434). PR [#439](https://github.com/tiangolo/sqlmodel/pull/439) by [@daniil-berg](https://github.com/daniil-berg).
|
||||
|
||||
### Docs
|
||||
|
||||
* 📝 Clarify description of in-memory SQLite database in `docs/tutorial/create-db-and-table.md`. PR [#601](https://github.com/tiangolo/sqlmodel/pull/601) by [@SimonCW](https://github.com/SimonCW).
|
||||
* 📝 Tweak wording in `docs/tutorial/fastapi/multiple-models.md`. PR [#674](https://github.com/tiangolo/sqlmodel/pull/674) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ✏️ Fix contributing instructions to run tests, update script name. PR [#634](https://github.com/tiangolo/sqlmodel/pull/634) by [@PookieBuns](https://github.com/PookieBuns).
|
||||
* 📝 Update link to docs for intro to databases. PR [#593](https://github.com/tiangolo/sqlmodel/pull/593) by [@abenezerBelachew](https://github.com/abenezerBelachew).
|
||||
* 📝 Update docs, use `offset` in example with `limit` and `where`. PR [#273](https://github.com/tiangolo/sqlmodel/pull/273) by [@jbmchuck](https://github.com/jbmchuck).
|
||||
* 📝 Fix docs for Pydantic's fields using `le` (`lte` is invalid, use `le` ). PR [#207](https://github.com/tiangolo/sqlmodel/pull/207) by [@jrycw](https://github.com/jrycw).
|
||||
* 📝 Update outdated link in `docs/db-to-code.md`. PR [#649](https://github.com/tiangolo/sqlmodel/pull/649) by [@MatveyF](https://github.com/MatveyF).
|
||||
* ✏️ Fix typos found with codespell. PR [#520](https://github.com/tiangolo/sqlmodel/pull/520) by [@kianmeng](https://github.com/kianmeng).
|
||||
* 📝 Fix typos (duplication) in main page. PR [#631](https://github.com/tiangolo/sqlmodel/pull/631) by [@Mr-DRP](https://github.com/Mr-DRP).
|
||||
* 📝 Update release notes, add second author to PR. PR [#429](https://github.com/tiangolo/sqlmodel/pull/429) by [@br-follow](https://github.com/br-follow).
|
||||
* 📝 Update instructions about how to make a foreign key required in `docs/tutorial/relationship-attributes/define-relationships-attributes.md`. PR [#474](https://github.com/tiangolo/sqlmodel/pull/474) by [@jalvaradosegura](https://github.com/jalvaradosegura).
|
||||
* 📝 Update help SQLModel docs. PR [#548](https://github.com/tiangolo/sqlmodel/pull/548) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ✏️ Fix typo in internal function name `get_sqlachemy_type()`. PR [#496](https://github.com/tiangolo/sqlmodel/pull/496) by [@cmarqu](https://github.com/cmarqu).
|
||||
* ✏️ Fix typo in docs. PR [#446](https://github.com/tiangolo/sqlmodel/pull/446) by [@davidbrochart](https://github.com/davidbrochart).
|
||||
* ✏️ Fix typo in `docs/tutorial/create-db-and-table.md`. PR [#477](https://github.com/tiangolo/sqlmodel/pull/477) by [@FluffyDietEngine](https://github.com/FluffyDietEngine).
|
||||
* ✏️ Fix small typos in docs. PR [#481](https://github.com/tiangolo/sqlmodel/pull/481) by [@micuffaro](https://github.com/micuffaro).
|
||||
|
||||
### Internal
|
||||
|
||||
* ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#672](https://github.com/tiangolo/sqlmodel/pull/672) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
|
||||
* ⬆ Bump dawidd6/action-download-artifact from 2.24.2 to 2.28.0. PR [#660](https://github.com/tiangolo/sqlmodel/pull/660) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ✅ Refactor OpenAPI FastAPI tests to simplify updating them later, this moves things around without changes. PR [#671](https://github.com/tiangolo/sqlmodel/pull/671) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Bump actions/checkout from 3 to 4. PR [#670](https://github.com/tiangolo/sqlmodel/pull/670) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* 🔧 Update mypy config, use `strict = true` instead of manual configs. PR [#428](https://github.com/tiangolo/sqlmodel/pull/428) by [@michaeloliverx](https://github.com/michaeloliverx).
|
||||
* ⬆️ Upgrade MkDocs Material. PR [#668](https://github.com/tiangolo/sqlmodel/pull/668) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🎨 Update docs format and references with pre-commit and Ruff. PR [#667](https://github.com/tiangolo/sqlmodel/pull/667) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🎨 Run pre-commit on all files and autoformat. PR [#666](https://github.com/tiangolo/sqlmodel/pull/666) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Move to Ruff and add pre-commit. PR [#661](https://github.com/tiangolo/sqlmodel/pull/661) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🛠️ Add `CITATION.cff` file for academic citations. PR [#13](https://github.com/tiangolo/sqlmodel/pull/13) by [@sugatoray](https://github.com/sugatoray).
|
||||
* 👷 Update docs deployments to Cloudflare. PR [#630](https://github.com/tiangolo/sqlmodel/pull/630) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷♂️ Upgrade CI for docs. PR [#628](https://github.com/tiangolo/sqlmodel/pull/628) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Update CI debug mode with Tmate. PR [#629](https://github.com/tiangolo/sqlmodel/pull/629) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Update latest changes token. PR [#616](https://github.com/tiangolo/sqlmodel/pull/616) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆️ Upgrade analytics. PR [#558](https://github.com/tiangolo/sqlmodel/pull/558) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔧 Update new issue chooser to point to GitHub Discussions. PR [#546](https://github.com/tiangolo/sqlmodel/pull/546) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔧 Add template for GitHub Discussion questions and update issues template. PR [#544](https://github.com/tiangolo/sqlmodel/pull/544) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Refactor CI artifact upload/download for docs previews. PR [#514](https://github.com/tiangolo/sqlmodel/pull/514) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Bump actions/cache from 2 to 3. PR [#497](https://github.com/tiangolo/sqlmodel/pull/497) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump dawidd6/action-download-artifact from 2.24.0 to 2.24.2. PR [#493](https://github.com/tiangolo/sqlmodel/pull/493) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* 🔧 Update Smokeshow coverage threshold. PR [#487](https://github.com/tiangolo/sqlmodel/pull/487) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Move from Codecov to Smokeshow. PR [#486](https://github.com/tiangolo/sqlmodel/pull/486) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Bump actions/setup-python from 2 to 4. PR [#411](https://github.com/tiangolo/sqlmodel/pull/411) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Update black requirement from ^21.5-beta.1 to ^22.10.0. PR [#460](https://github.com/tiangolo/sqlmodel/pull/460) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ➕ Add extra dev dependencies for MkDocs Material. PR [#485](https://github.com/tiangolo/sqlmodel/pull/485) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Update mypy requirement from 0.930 to 0.971. PR [#380](https://github.com/tiangolo/sqlmodel/pull/380) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Update coverage requirement from ^5.5 to ^6.2. PR [#171](https://github.com/tiangolo/sqlmodel/pull/171) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump codecov/codecov-action from 2 to 3. PR [#415](https://github.com/tiangolo/sqlmodel/pull/415) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump actions/upload-artifact from 2 to 3. PR [#412](https://github.com/tiangolo/sqlmodel/pull/412) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Update flake8 requirement from ^3.9.2 to ^5.0.4. PR [#396](https://github.com/tiangolo/sqlmodel/pull/396) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Update pytest requirement from ^6.2.4 to ^7.0.1. PR [#242](https://github.com/tiangolo/sqlmodel/pull/242) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump actions/checkout from 2 to 3.1.0. PR [#458](https://github.com/tiangolo/sqlmodel/pull/458) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump dawidd6/action-download-artifact from 2.9.0 to 2.24.0. PR [#470](https://github.com/tiangolo/sqlmodel/pull/470) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* 👷 Update Dependabot config. PR [#484](https://github.com/tiangolo/sqlmodel/pull/484) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Fixes
|
||||
|
||||
* 🐛 Fix auto detecting and setting `nullable`, allowing overrides in field. PR [#423](https://github.com/tiangolo/sqlmodel/pull/423) by [@JonasKs](https://github.com/JonasKs) and [@br-follow](https://github.com/br-follow).
|
||||
* ♻️ Update `expresion.py`, sync from Jinja2 template, implement `inherit_cache` to solve errors like: `SAWarning: Class SelectOfScalar will not make use of SQL compilation caching`. PR [#422](https://github.com/tiangolo/sqlmodel/pull/422) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Docs
|
||||
|
||||
* 📝 Adjust and clarify docs for `docs/tutorial/create-db-and-table.md`. PR [#426](https://github.com/tiangolo/sqlmodel/pull/426) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ✏ Fix typo in `docs/tutorial/connect/remove-data-connections.md`. PR [#421](https://github.com/tiangolo/sqlmodel/pull/421) by [@VerdantFox](https://github.com/VerdantFox).
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Allow setting `unique` in `Field()` for a column. PR [#83](https://github.com/tiangolo/sqlmodel/pull/83) by [@raphaelgibson](https://github.com/raphaelgibson).
|
||||
* ✨ Update GUID handling to use stdlib `UUID.hex` instead of an `int`. PR [#26](https://github.com/tiangolo/sqlmodel/pull/26) by [@andrewbolster](https://github.com/andrewbolster).
|
||||
* ✨ Raise an exception when using a Pydantic field type with no matching SQLAlchemy type. PR [#18](https://github.com/tiangolo/sqlmodel/pull/18) by [@elben10](https://github.com/elben10).
|
||||
* ⬆ Upgrade constrain for SQLAlchemy = ">=1.4.17,<=1.4.41". PR [#371](https://github.com/tiangolo/sqlmodel/pull/371) by [@RobertRosca](https://github.com/RobertRosca).
|
||||
* ✨ Add new `Session.get()` parameter `execution_options`. PR [#302](https://github.com/tiangolo/sqlmodel/pull/302) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Fixes
|
||||
|
||||
* 🐛 Fix type annotations for `Model.parse_obj()`, and `Model.validate()`. PR [#321](https://github.com/tiangolo/sqlmodel/pull/321) by [@phi-friday](https://github.com/phi-friday).
|
||||
* 🐛 Fix `Select` and `SelectOfScalar` to inherit cache to avoid warning: `SAWarning: Class SelectOfScalar will not make use of SQL compilation caching`. PR [#234](https://github.com/tiangolo/sqlmodel/pull/234) by [@rabinadk1](https://github.com/rabinadk1).
|
||||
* 🐛 Fix handling validators for non-default values. PR [#253](https://github.com/tiangolo/sqlmodel/pull/253) by [@byrman](https://github.com/byrman).
|
||||
* 🐛 Fix fields marked as "set" in models. PR [#117](https://github.com/tiangolo/sqlmodel/pull/117) by [@statt8900](https://github.com/statt8900).
|
||||
* 🐛 Fix Enum handling in SQLAlchemy. PR [#165](https://github.com/tiangolo/sqlmodel/pull/165) by [@chriswhite199](https://github.com/chriswhite199).
|
||||
* 🐛 Fix setting nullable property of Fields that don't accept `None`. PR [#79](https://github.com/tiangolo/sqlmodel/pull/79) by [@van51](https://github.com/van51).
|
||||
* 🐛 Fix SQLAlchemy version 1.4.36 breaks SQLModel relationships (#315). PR [#322](https://github.com/tiangolo/sqlmodel/pull/322) by [@byrman](https://github.com/byrman).
|
||||
|
||||
### Docs
|
||||
|
||||
* 📝 Update docs for models for updating, `id` should not be updatable. PR [#335](https://github.com/tiangolo/sqlmodel/pull/335) by [@kurtportelli](https://github.com/kurtportelli).
|
||||
* ✏ Fix broken variable/typo in docs for Read Relationships, `hero_spider_boy.id` => `hero_spider_boy.team_id`. PR [#106](https://github.com/tiangolo/sqlmodel/pull/106) by [@yoannmos](https://github.com/yoannmos).
|
||||
* 🎨 Remove unwanted highlight in the docs. PR [#233](https://github.com/tiangolo/sqlmodel/pull/233) by [@jalvaradosegura](https://github.com/jalvaradosegura).
|
||||
* ✏ Fix typos in `docs/databases.md` and `docs/tutorial/index.md`. PR [#35](https://github.com/tiangolo/sqlmodel/pull/35) by [@prrao87](https://github.com/prrao87).
|
||||
* ✏ Fix typo in `docs/tutorial/relationship-attributes/define-relationships-attributes.md`. PR [#239](https://github.com/tiangolo/sqlmodel/pull/239) by [@jalvaradosegura](https://github.com/jalvaradosegura).
|
||||
* ✏ Fix typo in `docs/tutorial/fastapi/simple-hero-api.md`. PR [#80](https://github.com/tiangolo/sqlmodel/pull/80) by [@joemudryk](https://github.com/joemudryk).
|
||||
* ✏ Fix typos in multiple files in the docs. PR [#400](https://github.com/tiangolo/sqlmodel/pull/400) by [@VictorGambarini](https://github.com/VictorGambarini).
|
||||
* ✏ Fix typo in `docs/tutorial/code-structure.md`. PR [#344](https://github.com/tiangolo/sqlmodel/pull/344) by [@marciomazza](https://github.com/marciomazza).
|
||||
* ✏ Fix typo in `docs/db-to-code.md`. PR [#155](https://github.com/tiangolo/sqlmodel/pull/155) by [@gr8jam](https://github.com/gr8jam).
|
||||
* ✏ Fix typo in `docs/contributing.md`. PR [#323](https://github.com/tiangolo/sqlmodel/pull/323) by [@Fardad13](https://github.com/Fardad13).
|
||||
* ✏ Fix typo in `docs/tutorial/fastapi/tests.md`. PR [#265](https://github.com/tiangolo/sqlmodel/pull/265) by [@johnhoman](https://github.com/johnhoman).
|
||||
* ✏ Fix typo in `docs/tutorial/where.md`. PR [#286](https://github.com/tiangolo/sqlmodel/pull/286) by [@jalvaradosegura](https://github.com/jalvaradosegura).
|
||||
* ✏ Fix typos in `docs/tutorial/fastapi/update.md`. PR [#268](https://github.com/tiangolo/sqlmodel/pull/268) by [@cirrusj](https://github.com/cirrusj).
|
||||
* ✏ Fix typo in `docs/tutorial/fastapi/simple-hero-api.md`. PR [#247](https://github.com/tiangolo/sqlmodel/pull/247) by [@hao-wang](https://github.com/hao-wang).
|
||||
* ✏ Fix typos in `docs/tutorial/automatic-id-none-refresh.md`, `docs/tutorial/fastapi/update.md`, `docs/tutorial/select.md`. PR [#185](https://github.com/tiangolo/sqlmodel/pull/185) by [@rootux](https://github.com/rootux).
|
||||
* ✏ Fix typo in `docs/databases.md`. PR [#177](https://github.com/tiangolo/sqlmodel/pull/177) by [@seandlg](https://github.com/seandlg).
|
||||
* ✏ Fix typos in `docs/tutorial/fastapi/update.md`. PR [#162](https://github.com/tiangolo/sqlmodel/pull/162) by [@wmcgee3](https://github.com/wmcgee3).
|
||||
* ✏ Fix typos in `docs/tutorial/code-structure.md`, `docs/tutorial/fastapi/multiple-models.md`, `docs/tutorial/fastapi/simple-hero-api.md`, `docs/tutorial/many-to-many/index.md`. PR [#116](https://github.com/tiangolo/sqlmodel/pull/116) by [@moonso](https://github.com/moonso).
|
||||
* ✏ Fix typo in `docs/tutorial/fastapi/teams.md`. PR [#154](https://github.com/tiangolo/sqlmodel/pull/154) by [@chrisgoddard](https://github.com/chrisgoddard).
|
||||
* ✏ Fix typo variable in example about relationships and `back_populates`, always use `hero` instead of `owner`. PR [#120](https://github.com/tiangolo/sqlmodel/pull/120) by [@onionj](https://github.com/onionj).
|
||||
* ✏ Fix typo in `docs/tutorial/fastapi/tests.md`. PR [#113](https://github.com/tiangolo/sqlmodel/pull/113) by [@feanil](https://github.com/feanil).
|
||||
* ✏ Fix typo in `docs/tutorial/where.md`. PR [#72](https://github.com/tiangolo/sqlmodel/pull/72) by [@ZettZet](https://github.com/ZettZet).
|
||||
* ✏ Fix typo in `docs/tutorial/code-structure.md`. PR [#91](https://github.com/tiangolo/sqlmodel/pull/91) by [@dhiraj](https://github.com/dhiraj).
|
||||
* ✏ Fix broken link to newsletter sign-up in `docs/help.md`. PR [#84](https://github.com/tiangolo/sqlmodel/pull/84) by [@mborus](https://github.com/mborus).
|
||||
* ✏ Fix typos in `docs/tutorial/many-to-many/create-models-with-link.md`. PR [#45](https://github.com/tiangolo/sqlmodel/pull/45) by [@xginn8](https://github.com/xginn8).
|
||||
* ✏ Fix typo in `docs/tutorial/index.md`. PR [#398](https://github.com/tiangolo/sqlmodel/pull/398) by [@ryangrose](https://github.com/ryangrose).
|
||||
|
||||
### Internal
|
||||
|
||||
* ♻ Refactor internal statements to simplify code. PR [#53](https://github.com/tiangolo/sqlmodel/pull/53) by [@yezz123](https://github.com/yezz123).
|
||||
* ♻ Refactor internal imports to reduce redundancy. PR [#272](https://github.com/tiangolo/sqlmodel/pull/272) by [@aminalaee](https://github.com/aminalaee).
|
||||
* ⬆ Update development requirement for FastAPI from `^0.68.0` to `^0.68.1`. PR [#48](https://github.com/tiangolo/sqlmodel/pull/48) by [@alucarddelta](https://github.com/alucarddelta).
|
||||
* ⏪ Revert upgrade Poetry, to make a release that supports Python 3.6 first. PR [#417](https://github.com/tiangolo/sqlmodel/pull/417) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Add dependabot for GitHub Actions. PR [#410](https://github.com/tiangolo/sqlmodel/pull/410) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆️ Upgrade Poetry to version `==1.2.0b1`. PR [#303](https://github.com/tiangolo/sqlmodel/pull/303) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Add CI for Python 3.10. PR [#305](https://github.com/tiangolo/sqlmodel/pull/305) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 📝 Add Jina's QA Bot to the docs to help people that want to ask quick questions. PR [#263](https://github.com/tiangolo/sqlmodel/pull/263) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 👷 Upgrade Codecov GitHub Action. PR [#304](https://github.com/tiangolo/sqlmodel/pull/304) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 💚 Only run CI on push when on master, to avoid duplicate runs on PRs. PR [#244](https://github.com/tiangolo/sqlmodel/pull/244) by [@tiangolo](https://github.com/tiangolo).
|
||||
* 🔧 Upgrade MkDocs Material and update configs. PR [#217](https://github.com/tiangolo/sqlmodel/pull/217) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ⬆ Upgrade mypy, fix type annotations. PR [#218](https://github.com/tiangolo/sqlmodel/pull/218) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
**SQLModel** no longer creates indexes by default for every column, indexes are now opt-in. You can read more about it in PR [#205](https://github.com/tiangolo/sqlmodel/pull/205).
|
||||
|
||||
Before this change, if you had a model like this:
|
||||
|
||||
```Python
|
||||
from typing import Optional
|
||||
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
class Hero(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str
|
||||
secret_name: str
|
||||
age: Optional[int] = None
|
||||
```
|
||||
|
||||
...when creating the tables, SQLModel version `0.0.5` and below, would also create an index for `name`, one for `secret_name`, and one for `age` (`id` is the primary key, so it doesn't need an additional index).
|
||||
|
||||
If you depended on having an index for each one of those columns, now you can (and would have to) define them explicitly:
|
||||
|
||||
```Python
|
||||
class Hero(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
name: str = Field(index=True)
|
||||
secret_name: str = Field(index=True)
|
||||
age: Optional[int] = Field(default=None, index=True)
|
||||
```
|
||||
|
||||
There's a high chance you don't need indexes for all the columns. For example, you might only need indexes for `name` and `age`, but not for `secret_name`. In that case, you could define the model as:
|
||||
|
||||
```Python
|
||||
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)
|
||||
```
|
||||
|
||||
If you already created your database tables with SQLModel using versions `0.0.5` or below, it would have also created those indexes in the database. In that case, you might want to manually drop (remove) some of those indexes, if they are unnecessary, to avoid the extra cost in performance and space.
|
||||
|
||||
Depending on the database you are using, there will be a different way to find the available indexes.
|
||||
|
||||
For example, let's say you no longer need the index for `secret_name`. You could check the current indexes in the database and find the one for `secret_name`, it could be named `ix_hero_secret_name`. Then you can remove it with SQL:
|
||||
|
||||
```SQL
|
||||
DROP INDEX ix_hero_secret_name
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```SQL
|
||||
DROP INDEX ix_hero_secret_name ON hero;
|
||||
```
|
||||
|
||||
Here's the new, extensive documentation explaining indexes and how to use them: [Indexes - Optimize Queries](https://sqlmodel.tiangolo.com/tutorial/indexes/).
|
||||
|
||||
### Docs
|
||||
|
||||
* ✨ Document indexes and make them opt-in. Here's the new documentation: [Indexes - Optimize Queries](https://sqlmodel.tiangolo.com/tutorial/indexes/). This is the same change described above in **Breaking Changes**. PR [#205](https://github.com/tiangolo/sqlmodel/pull/205) by [@tiangolo](https://github.com/tiangolo).
|
||||
* ✏ Fix typo in FastAPI tutorial. PR [#192](https://github.com/tiangolo/sqlmodel/pull/192) by [@yaquelinehoyos](https://github.com/yaquelinehoyos).
|
||||
* 📝 Add links to the license file. PR [#29](https://github.com/tiangolo/sqlmodel/pull/29) by [@sobolevn](https://github.com/sobolevn).
|
||||
* ✏ Fix typos in docs titles. PR [#28](https://github.com/tiangolo/sqlmodel/pull/28) by [@Batalex](https://github.com/Batalex).
|
||||
* ✏ Fix multiple typos and some rewording. PR [#22](https://github.com/tiangolo/sqlmodel/pull/22) by [@egrim](https://github.com/egrim).
|
||||
* ✏ Fix typo in `docs/tutorial/automatic-id-none-refresh.md`. PR [#14](https://github.com/tiangolo/sqlmodel/pull/14) by [@leynier](https://github.com/leynier).
|
||||
* ✏ Fix typos in `docs/tutorial/index.md` and `docs/databases.md`. PR [#5](https://github.com/tiangolo/sqlmodel/pull/5) by [@sebastianmarines](https://github.com/sebastianmarines).
|
||||
|
||||
## 0.0.5
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Automatic IDs, None Defaults, and Refreshing Data
|
||||
|
||||
In the previous chapter we saw how to add rows to the database using **SQLModel**.
|
||||
In the previous chapter, we saw how to add rows to the database using **SQLModel**.
|
||||
|
||||
Now let's talk a bit about why the `id` field **can't be `NULL`** on the database because it's a **primary key**, and we declare it using `Field(primary_key=True)`.
|
||||
|
||||
@@ -11,7 +11,7 @@ But the same `id` field actually **can be `None`** in the Python code, so we dec
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:6-10]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -36,7 +36,7 @@ When we create a new `Hero` instance, we don't set the `id`:
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-26]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -68,7 +68,7 @@ If we ran this code before saving the hero to the database and the `hero_1.id` w
|
||||
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
|
||||
```
|
||||
|
||||
But by declaring it with `Optional[int]` the editor will help us to avoid writing broken code by showing us a warning telling us that the code could be invalid if `hero_1.id` is `None`. 🔍
|
||||
But by declaring it with `Optional[int]`, the editor will help us to avoid writing broken code by showing us a warning telling us that the code could be invalid if `hero_1.id` is `None`. 🔍
|
||||
|
||||
## Print the Default `id` Values
|
||||
|
||||
@@ -79,7 +79,7 @@ We can confirm that by printing our heroes before adding them to the database:
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-31]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -98,7 +98,7 @@ That will output:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
Before interacting with the database
|
||||
Hero 1: id=None name='Deadpond' secret_name='Dive Wilson' age=None
|
||||
@@ -118,14 +118,14 @@ What happens when we `add` these objects to the **session**?
|
||||
|
||||
After we add the `Hero` instance objects to the **session**, the IDs are *still* `None`.
|
||||
|
||||
We can verify by creating a session using a `with` block, and adding the objects. And then printing them again:
|
||||
We can verify by creating a session using a `with` block and adding the objects. And then printing them again:
|
||||
|
||||
```Python hl_lines="19-21"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:23-41]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -144,7 +144,7 @@ This will, again, output the `id`s of the objects as `None`:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
After adding to the session
|
||||
Hero 1: id=None name='Deadpond' secret_name='Dive Wilson' age=None
|
||||
@@ -165,7 +165,7 @@ Then we can `commit` the changes in the session, and print again:
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-48]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -184,7 +184,7 @@ And now, something unexpected happens, look at the output, it seems as if the `H
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
// Here the engine talks to the database, the SQL part
|
||||
INFO Engine BEGIN (implicit)
|
||||
@@ -198,9 +198,9 @@ INFO Engine COMMIT
|
||||
|
||||
// And now our prints
|
||||
After committing the session
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
|
||||
// What is happening here? 😱
|
||||
```
|
||||
@@ -238,7 +238,7 @@ To confirm and understand how this **automatic expiration and refresh** of data
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-58]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -271,21 +271,21 @@ Let's see how it works:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
// After committing, the objects are expired and have no values
|
||||
After committing the session
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
|
||||
// Now we will access an attribute like the ID, this is the first print
|
||||
After committing the session, show IDs
|
||||
|
||||
// Notice that before printing the first ID, the Session makes the Engine go to the database to refresh the data 🤓
|
||||
INFO Engine BEGIN (implicit)
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00017s] (1,)
|
||||
|
||||
@@ -293,8 +293,8 @@ INFO Engine [generated in 0.00017s] (1,)
|
||||
Hero 1 ID: 1
|
||||
|
||||
// Before the next print, refresh the data for the second object
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.001245s ago] (2,)
|
||||
|
||||
@@ -302,8 +302,8 @@ INFO Engine [cached since 0.001245s ago] (2,)
|
||||
Hero 2 ID: 2
|
||||
|
||||
// Before the third print, refresh its data
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.002215s ago] (3,)
|
||||
|
||||
@@ -335,7 +335,7 @@ You can do that too with `session.refresh(object)`:
|
||||
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial001.py[ln:33-67]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -362,23 +362,23 @@ Here's how the output would look like:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
// The first refresh
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00024s] (1,)
|
||||
|
||||
// The second refresh
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.001487s ago] (2,)
|
||||
|
||||
// The third refresh
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.002377s ago] (3,)
|
||||
|
||||
@@ -399,7 +399,7 @@ In this case, after committing the object to the database with the **session**,
|
||||
|
||||
## Print Data After Closing the Session
|
||||
|
||||
Now, as a fnal experiment, we can also print data after the **session** is closed.
|
||||
Now, as a final experiment, we can also print data after the **session** is closed.
|
||||
|
||||
There are no surprises here, it still works:
|
||||
|
||||
@@ -427,7 +427,7 @@ And the output shows again the same data:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Output above ommitted 👆
|
||||
// Output above omitted 👆
|
||||
|
||||
// By finishing the with block, the Session is closed, including a rollback of any pending transaction that could have been there and was not committed
|
||||
INFO Engine ROLLBACK
|
||||
@@ -450,7 +450,7 @@ Now let's review all this code once again.
|
||||
|
||||
And as we created the **engine** with `echo=True`, we can see the SQL statements being executed at each step.
|
||||
|
||||
```{ .python .annotate hl_lines="54" }
|
||||
```{ .python .annotate }
|
||||
{!./docs_src/tutorial/automatic_id_none_refresh/tutorial002.py!}
|
||||
```
|
||||
|
||||
@@ -468,12 +468,12 @@ INFO Engine PRAGMA main.table_info("hero")
|
||||
INFO Engine [raw sql] ()
|
||||
INFO Engine PRAGMA temp.table_info("hero")
|
||||
INFO Engine [raw sql] ()
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
@@ -497,23 +497,23 @@ INFO Engine INSERT INTO hero (name, secret_name, age) VALUES (?, ?, ?)
|
||||
INFO Engine [cached since 0.001483s ago] ('Rusty-Man', 'Tommy Sharp', 48)
|
||||
INFO Engine COMMIT
|
||||
After committing the session
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
Hero 1:
|
||||
Hero 2:
|
||||
Hero 3:
|
||||
After committing the session, show IDs
|
||||
INFO Engine BEGIN (implicit)
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00029s] (1,)
|
||||
Hero 1 ID: 1
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.002132s ago] (2,)
|
||||
Hero 2 ID: 2
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id AS hero_id, hero.name AS hero_name, hero.secret_name AS hero_secret_name, hero.age AS hero_age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.003367s ago] (3,)
|
||||
Hero 3 ID: 3
|
||||
@@ -521,16 +521,16 @@ After committing the session, show names
|
||||
Hero 1 name: Deadpond
|
||||
Hero 2 name: Spider-Boy
|
||||
Hero 3 name: Rusty-Man
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00025s] (1,)
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.001583s ago] (2,)
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.002722s ago] (3,)
|
||||
After refreshing the heroes
|
||||
|
||||
@@ -8,7 +8,7 @@ The class `Hero` has a reference to the class `Team` internally.
|
||||
|
||||
But the class `Team` also has a reference to the class `Hero`.
|
||||
|
||||
So, if those two classes where in separate files and you tried to import the classes in each other's file directly, it would result in a **circular import**. 🔄
|
||||
So, if those two classes were in separate files and you tried to import the classes in each other's file directly, it would result in a **circular import**. 🔄
|
||||
|
||||
And Python will not be able to handle it and will throw an error. 🚨
|
||||
|
||||
@@ -168,9 +168,9 @@ Let's assume that now the file structure is:
|
||||
|
||||
### Circular Imports and Type Annotations
|
||||
|
||||
The problem with circular imports is that Python can't resolve them at <abbr title="While it is executing the program, as oposed to the code as just text in a file stored on disk.">*runtime*</abbr>.
|
||||
The problem with circular imports is that Python can't resolve them at <abbr title="While it is executing the program, as opposed to the code as just text in a file stored on disk.">*runtime*</abbr>.
|
||||
|
||||
but when using Python **type annotations** it's very common to need to declare the type of some variables with classes imported from other files.
|
||||
But when using Python **type annotations** it's very common to need to declare the type of some variables with classes imported from other files.
|
||||
|
||||
And the files with those classes might **also need to import** more things from the first files.
|
||||
|
||||
@@ -198,7 +198,7 @@ It has a value of `True` for editors and tools that analyze the code with the ty
|
||||
|
||||
But when Python is executing, its value is `False`.
|
||||
|
||||
So, we can us it in an `if` block and import things inside the `if` block. And they will be "imported" only for editors, but not at runtime.
|
||||
So, we can use it in an `if` block and import things inside the `if` block. And they will be "imported" only for editors, but not at runtime.
|
||||
|
||||
### Hero Model File
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ As the `Hero` class model now has a field (column, attribute) `team_id`, we can
|
||||
|
||||
We haven't committed this hero to the database yet, but there are already a couple of things to pay **attention** to.
|
||||
|
||||
If the database already had some teams, we wouldn't even know **what is the ID** that is going to be automatically assigned to each team by the database, for example, we couldn't just guess `1` or `2`.
|
||||
If the database already had some teams, we wouldn't even know **what is the ID** that is going to be automatically assigned to each team by the database, for example, we couldn't just guess `1` or `2`.
|
||||
|
||||
But once the team is created and committed to the database, we can access the object's `id` field to get that ID.
|
||||
|
||||
@@ -171,8 +171,8 @@ That line alone would generate an output of:
|
||||
|
||||
```
|
||||
INFO Engine BEGIN (implicit)
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team
|
||||
WHERE team.id = ?
|
||||
INFO Engine [generated in 0.00025s] (2,)
|
||||
```
|
||||
@@ -199,8 +199,8 @@ Let's now create two more heroes:
|
||||
When creating `hero_rusty_man`, we are accessing `team_preventers.id`, so that will also trigger a refresh of its data, generating an output of:
|
||||
|
||||
```
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team
|
||||
WHERE team.id = ?
|
||||
INFO Engine [cached since 0.001795s ago] (1,)
|
||||
```
|
||||
@@ -256,18 +256,18 @@ $ python app.py
|
||||
INFO Engine BEGIN (implicit)
|
||||
|
||||
// Refresh the first hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00021s] (1,)
|
||||
// Refresh the second hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.001575s ago] (2,)
|
||||
// Refresh the third hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.002518s ago] (3,)
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ The `Team` model will be in a table automatically named `"team"`, and it will ha
|
||||
|
||||
* `id`, the primary key, automatically generated by the database
|
||||
* `name`, the name of the team
|
||||
* We also tell **SQLModel** to create an index for this column
|
||||
* `headquarters`, the headquarters of the team
|
||||
|
||||
And finally we mark it as a table in the config.
|
||||
@@ -105,9 +106,9 @@ This is the same model we have been using up to now, we are just adding the new
|
||||
|
||||
Most of that should look familiar:
|
||||
|
||||
The column will be named `team_id`. It will be an integer, and it could be `NULL` in the database (or `None` in Python), becase there could be some heroes that don't belong to any team.
|
||||
The column will be named `team_id`. It will be an integer, and it could be `NULL` in the database (or `None` in Python), because there could be some heroes that don't belong to any team.
|
||||
|
||||
As we don't have to explicitly pass `team_id=None` when creating a hero, we add a default of `None` to the `Field()`.
|
||||
We add a default of `None` to the `Field()` so we don't have to explicitly pass `team_id=None` when creating a hero.
|
||||
|
||||
Now, here's the new part:
|
||||
|
||||
@@ -190,24 +191,24 @@ INFO Engine PRAGMA temp.table_info("hero")
|
||||
INFO Engine [raw sql] ()
|
||||
|
||||
// Create the tables
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
CREATE TABLE team (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
headquarters VARCHAR NOT NULL,
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
headquarters VARCHAR NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
|
||||
INFO Engine [no key 0.00010s] ()
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
team_id INTEGER,
|
||||
PRIMARY KEY (id),
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
team_id INTEGER,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY(team_id) REFERENCES team (id)
|
||||
)
|
||||
|
||||
@@ -228,9 +229,9 @@ So, the first SQL could also be written as:
|
||||
|
||||
```SQL
|
||||
CREATE TABLE team (
|
||||
id INTEGER,
|
||||
name TEXT NOT NULL,
|
||||
headquarters TEXT NOT NULL,
|
||||
id INTEGER,
|
||||
name TEXT NOT NULL,
|
||||
headquarters TEXT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
```
|
||||
@@ -239,12 +240,12 @@ And the second table could be written as:
|
||||
|
||||
```SQL hl_lines="8"
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name TEXT NOT NULL,
|
||||
secret_name TEXT NOT NULL,
|
||||
age INTEGER,
|
||||
team_id INTEGER,
|
||||
PRIMARY KEY (id),
|
||||
id INTEGER,
|
||||
name TEXT NOT NULL,
|
||||
secret_name TEXT NOT NULL,
|
||||
age INTEGER,
|
||||
team_id INTEGER,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY(team_id) REFERENCES team (id)
|
||||
)
|
||||
```
|
||||
|
||||
@@ -203,8 +203,8 @@ $ python app.py
|
||||
// Previous output omitted 😉
|
||||
|
||||
// Get the heroes with their teams
|
||||
2021-08-09 08:55:50,682 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
FROM hero, team
|
||||
2021-08-09 08:55:50,682 INFO sqlalchemy.engine.Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
FROM hero, team
|
||||
WHERE hero.team_id = team.id
|
||||
2021-08-09 08:55:50,682 INFO sqlalchemy.engine.Engine [no key 0.00015s] ()
|
||||
|
||||
@@ -323,7 +323,7 @@ $ python app.py
|
||||
// Previous output omitted 😉
|
||||
|
||||
// Select using a JOIN with automatic ON
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
FROM hero JOIN team ON team.id = hero.team_id
|
||||
INFO Engine [no key 0.00032s] ()
|
||||
|
||||
@@ -458,7 +458,7 @@ $ python app.py
|
||||
// Previous output omitted 😉
|
||||
|
||||
// SELECT using LEFT OUTER JOIN
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
FROM hero LEFT OUTER JOIN team ON team.id = hero.team_id
|
||||
|
||||
INFO Engine [no key 0.00051s] ()
|
||||
@@ -522,9 +522,9 @@ If we run that, it would output:
|
||||
$ python app.py
|
||||
|
||||
// Select only the hero data
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
// But still join with the team table
|
||||
FROM hero JOIN team ON team.id = hero.team_id
|
||||
FROM hero JOIN team ON team.id = hero.team_id
|
||||
// And filter with WHERE to get only the Preventers
|
||||
WHERE team.name = ?
|
||||
INFO Engine [no key 0.00066s] ('Preventers',)
|
||||
@@ -564,9 +564,9 @@ And if we run that, it will output:
|
||||
$ python app.py
|
||||
|
||||
// Select the hero and the team data
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id, team.id AS id_1, team.name AS name_1, team.headquarters
|
||||
// Join the hero with the team table
|
||||
FROM hero JOIN team ON team.id = hero.team_id
|
||||
FROM hero JOIN team ON team.id = hero.team_id
|
||||
// Filter with WHERE to get only Preventers
|
||||
WHERE team.name = ?
|
||||
INFO Engine [no key 0.00018s] ('Preventers',)
|
||||
|
||||
@@ -46,7 +46,7 @@ We will continue with the code from the previous chapter.
|
||||
|
||||
## Break a Connection
|
||||
|
||||
We don't really have to delete anyting to break a connection. We can just assign `None` to the foreign key, in this case, to the `team_id`.
|
||||
We don't really have to delete anything to break a connection. We can just assign `None` to the foreign key, in this case, to the `team_id`.
|
||||
|
||||
Let's say **Spider-Boy** is tired of the lack of friendly neighbors and wants to get out of the **Preventers**.
|
||||
|
||||
@@ -56,7 +56,7 @@ We can simply set the `team_id` to `None`, and now it doesn't have a connection
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/connect/delete/tutorial001.py[ln:31-32]!}
|
||||
|
||||
|
||||
# Previous code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/connect/delete/tutorial001.py[ln:68-72]!}
|
||||
@@ -94,8 +94,8 @@ INFO Engine COMMIT
|
||||
// Automatically start a new transaction
|
||||
INFO Engine BEGIN (implicit)
|
||||
// Refresh the hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.1661s ago] (3,)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ Doing it is just like updating any other field:
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/connect/update/tutorial001.py[ln:31-32]!}
|
||||
|
||||
|
||||
# Previous code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/connect/update/tutorial001.py[ln:62-66]!}
|
||||
@@ -94,8 +94,8 @@ INFO Engine COMMIT
|
||||
// Automatically start a new transaction
|
||||
INFO Engine BEGIN (implicit)
|
||||
// Refresh the hero data
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age, hero.team_id
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.08837s ago] (3,)
|
||||
|
||||
|
||||
@@ -164,6 +164,6 @@ Of course, you can also go and take a full SQL course or read a book about SQL,
|
||||
|
||||
We saw how to interact with SQLite databases in files using **DB Browser for SQLite** in a visual user interface.
|
||||
|
||||
We also saw how to use it to write some SQL directly to the SQLite database. This will be useful to verify the data in the database is looking correclty, to debug, etc.
|
||||
We also saw how to use it to write some SQL directly to the SQLite database. This will be useful to verify the data in the database is looking correctly, to debug, etc.
|
||||
|
||||
In the next chapters we will start using **SQLModel** to interact with the database, and we will continue to use **DB Browser for SQLite** at the same time to look at the database underneath. 🔍
|
||||
|
||||
@@ -220,7 +220,7 @@ Each supported database has it's own URL type. For example, for **SQLite** it is
|
||||
* `sqlite:///databases/local/application.db`
|
||||
* `sqlite:///db.sqlite`
|
||||
|
||||
For SQLAlchemy, there's also a special one, which is a database all *in memory*, this means that it is deleted after the program terminates, and it's also very fast:
|
||||
SQLite supports a special database that lives all *in memory*. Hence, it's very fast, but be careful, the database gets deleted after the program terminates. You can specify this in-memory database by using just two slash characters (`//`) and no file name:
|
||||
|
||||
* `sqlite://`
|
||||
|
||||
@@ -415,22 +415,22 @@ Now run the program with Python:
|
||||
// We set echo=True, so this will show the SQL code
|
||||
$ python app.py
|
||||
|
||||
// First, some boilerplate SQL that we are not that intereted in
|
||||
// First, some boilerplate SQL that we are not that interested in
|
||||
|
||||
INFO Engine BEGIN (implicit)
|
||||
INFO Engine PRAGMA main.table_info("hero")
|
||||
INFO Engine [raw sql] ()
|
||||
INFO Engine PRAGMA temp.table_info("hero")
|
||||
INFO Engine [raw sql] ()
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
|
||||
// Finally, the glorious SQL to create the table ✨
|
||||
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
@@ -498,7 +498,7 @@ In this example it's just the `SQLModel.metadata.create_all(engine)`.
|
||||
|
||||
Let's put it in a function `create_db_and_tables()`:
|
||||
|
||||
```Python hl_lines="22-23"
|
||||
```Python hl_lines="19-20"
|
||||
{!./docs_src/tutorial/create_db_and_table/tutorial002.py[ln:1-20]!}
|
||||
|
||||
# More code here later 👇
|
||||
@@ -513,9 +513,9 @@ Let's put it in a function `create_db_and_tables()`:
|
||||
|
||||
</details>
|
||||
|
||||
If `SQLModel.metadata.create_all(engine)` was not in a function and we tried to import something from this module (from this file) in another, it would try to create the database and table **every time**.
|
||||
If `SQLModel.metadata.create_all(engine)` was not in a function and we tried to import something from this module (from this file) in another, it would try to create the database and table **every time** we executed that other file that imported this module.
|
||||
|
||||
We don't want that to happen like that, only when we **intend** it to happen, that's why we put it in a function.
|
||||
We don't want that to happen like that, only when we **intend** it to happen, that's why we put it in a function, because we can make sure that the tables are created only when we call that function, and not when this module is imported somewhere else.
|
||||
|
||||
Now we would be able to, for example, import the `Hero` class in some other file without having those **side effects**.
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ $ python app.py
|
||||
|
||||
// The SELECT with WHERE
|
||||
INFO Engine BEGIN (implicit)
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.name = ?
|
||||
INFO Engine [no key 0.00011s] ('Spider-Youngster',)
|
||||
|
||||
@@ -272,8 +272,8 @@ $ python app.py
|
||||
INFO Engine BEGIN (implicit)
|
||||
|
||||
// SQL to search for the hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.name = ?
|
||||
INFO Engine [no key 0.00013s] ('Spider-Youngster',)
|
||||
```
|
||||
|
||||
@@ -39,6 +39,6 @@ After deleting it successfully, we just return a response of:
|
||||
|
||||
## Recap
|
||||
|
||||
That's it, feel free to try it out in the interactve docs UI to delete some heroes. 💥
|
||||
That's it, feel free to try it out in the interactive docs UI to delete some heroes. 💥
|
||||
|
||||
Using **FastAPI** to read data and combining it with **SQLModel** makes it quite straightforward to delete data from the database.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Read Heroes with Limit and Offset wtih FastAPI
|
||||
# Read Heroes with Limit and Offset with FastAPI
|
||||
|
||||
When a client sends a request to get all the heroes, we have been returning them all.
|
||||
|
||||
But if we had **thousands** of heroes that could consume a lot of **computational resources**, network bandwith, etc.
|
||||
But if we had **thousands** of heroes that could consume a lot of **computational resources**, network bandwidth, etc.
|
||||
|
||||
So we probably want to limit it.
|
||||
So, we probably want to limit it.
|
||||
|
||||
Let's use the same **offset** and **limit** we learned about in the previous tutorial chapters for the API.
|
||||
|
||||
!!! info
|
||||
In many cases this is also called **pagination**.
|
||||
In many cases, this is also called **pagination**.
|
||||
|
||||
## Add a Limit and Offset to the Query Parameters
|
||||
|
||||
@@ -38,13 +38,13 @@ And by default, we will return a maximum of `100` heroes, so `limit` will have a
|
||||
|
||||
</details>
|
||||
|
||||
We want to allow clients to set a different `offset` and `limit` values.
|
||||
We want to allow clients to set different `offset` and `limit` values.
|
||||
|
||||
But we don't want them to be able to set a `limit` of something like `9999`, that's over `9000`! 😱
|
||||
|
||||
So, to prevent it, we add additional validation to the `limit` query parameter, declaring that it has to be **l**ess **t**han or **e**qual to `100` with `lte=100`.
|
||||
So, to prevent it, we add additional validation to the `limit` query parameter, declaring that it has to be **l**ess than or **e**qual to `100` with `le=100`.
|
||||
|
||||
This way, a client can decide to take less heroes if they want, but not more.
|
||||
This way, a client can decide to take fewer heroes if they want, but not more.
|
||||
|
||||
!!! info
|
||||
If you need to refresh how query parameters and their validation work, check out the docs in FastAPI:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
We have been using the same `Hero` model to declare the schema of the data we receive in the API, the table model in the database, and the schema of the data we send back in responses.
|
||||
|
||||
But in most of the cases there are slight differences, let's use multiple models to solve it.
|
||||
But in most of the cases, there are slight differences. Let's use multiple models to solve it.
|
||||
|
||||
Here you will see the main and biggest feature of **SQLModel**. 😎
|
||||
|
||||
@@ -10,7 +10,7 @@ Here you will see the main and biggest feature of **SQLModel**. 😎
|
||||
|
||||
Let's start by reviewing the automatically generated schemas from the docs UI.
|
||||
|
||||
For input we have:
|
||||
For input, we have:
|
||||
|
||||
<img class="shadow" alt="Interactive API docs UI" src="/img/tutorial/fastapi/simple-hero-api/image01.png">
|
||||
|
||||
@@ -20,7 +20,7 @@ This means that the client could try to use the same ID that already exists in t
|
||||
|
||||
That's not what we want.
|
||||
|
||||
We want the client to only send the data that is needed to create a new hero:
|
||||
We want the client only to send the data that is needed to create a new hero:
|
||||
|
||||
* `name`
|
||||
* `secret_name`
|
||||
@@ -53,17 +53,17 @@ Here's the weird thing, the `id` currently seems also "optional". 🤔
|
||||
|
||||
This is because in our **SQLModel** class we declare the `id` with `Optional[int]`, because it could be `None` in memory until we save it in the database and we finally get the actual ID.
|
||||
|
||||
But in the responses, we would always send a model from the database, and it would **always have an ID**. So the `id` in the responses could be declared as required too.
|
||||
But in the responses, we always send a model from the database, so it **always has an ID**. So the `id` in the responses can be declared as required.
|
||||
|
||||
This would mean that our application is making the compromise with the clients that if it sends a hero, it would for sure have an `id` with a value, it would not be `None`.
|
||||
This means that our application is making the promise to the clients that if it sends a hero, it will for sure have an `id` with a value, it will not be `None`.
|
||||
|
||||
### Why Is it Important to Compromise with the Responses
|
||||
### Why Is it Important to Have a Contract for Responses
|
||||
|
||||
The ultimate goal of an API is for some **clients to use it**.
|
||||
|
||||
The clients could be a frontend application, a command line program, a graphical user interface, a mobile application, another backend application, etc.
|
||||
|
||||
And the code those clients write depend on what our API tells them they **need to send**, and what they can **expect to receive**.
|
||||
And the code those clients write depends on what our API tells them they **need to send**, and what they can **expect to receive**.
|
||||
|
||||
Making both sides very clear will make it much easier to interact with the API.
|
||||
|
||||
@@ -164,7 +164,7 @@ Let's first check how is the process to create a hero now:
|
||||
|
||||
Let's check that in detail.
|
||||
|
||||
Now we use the type annotation `HeroCreate` for the request JSON data, in the `hero` parameter of the **path operation function**.
|
||||
Now we use the type annotation `HeroCreate` for the request JSON data in the `hero` parameter of the **path operation function**.
|
||||
|
||||
```Python hl_lines="3"
|
||||
# Code above omitted 👆
|
||||
@@ -180,9 +180,9 @@ The method `.from_orm()` reads data from another object with attributes and crea
|
||||
|
||||
The alternative is `Hero.parse_obj()` that reads data from a dictionary.
|
||||
|
||||
But as in this case we have a `HeroCreate` instance in the `hero` variable, this is an object with attributes, so we use `.from_orm()` to read those attributes.
|
||||
But as in this case, we have a `HeroCreate` instance in the `hero` variable. This is an object with attributes, so we use `.from_orm()` to read those attributes.
|
||||
|
||||
With this we create a new `Hero` instance (the one for the database) and put it in the variable `db_hero` from the data in the `hero` variable that is the `HeroCreate` instance we received from the request.
|
||||
With this, we create a new `Hero` instance (the one for the database) and put it in the variable `db_hero` from the data in the `hero` variable that is the `HeroCreate` instance we received from the request.
|
||||
|
||||
```Python hl_lines="3"
|
||||
# Code above omitted 👆
|
||||
@@ -192,7 +192,7 @@ With this we create a new `Hero` instance (the one for the database) and put it
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
Then we just `add` it to the **session**, `commit`, and `refresh` it, and finally we return the same `db_hero` variable that has the just refreshed `Hero` instance.
|
||||
Then we just `add` it to the **session**, `commit`, and `refresh` it, and finally, we return the same `db_hero` variable that has the just refreshed `Hero` instance.
|
||||
|
||||
Because it is just refreshed, it has the `id` field set with a new ID taken from the database.
|
||||
|
||||
@@ -206,30 +206,30 @@ And now that we return it, FastAPI will validate the data with the `response_mod
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
This will validate that all the data that we promised is there, and will remove any data we didn't declare.
|
||||
This will validate that all the data that we promised is there and will remove any data we didn't declare.
|
||||
|
||||
!!! tip
|
||||
This filtering could be very important, and could be a very good security feature, for example to make sure you filter private data, hashed passwords, etc.
|
||||
This filtering could be very important and could be a very good security feature, for example, to make sure you filter private data, hashed passwords, etc.
|
||||
|
||||
You can read more about it in the <a href="https://fastapi.tiangolo.com/tutorial/response-model/" class="external-link" target="_blank">FastAPI docs about Response Model</a>.
|
||||
|
||||
In particular, it will make sure that the `id` is there, and that it is indeed an integer (and not `None`).
|
||||
In particular, it will make sure that the `id` is there and that it is indeed an integer (and not `None`).
|
||||
|
||||
## Shared Fields
|
||||
|
||||
But looking closely, we could see that these models have a lot of **duplicated information**.
|
||||
|
||||
All **the 3 models** declare that thay share some **common fields** that look exactly the same:
|
||||
All **the 3 models** declare that they share some **common fields** that look exactly the same:
|
||||
|
||||
* `name`, required
|
||||
* `secret_name`, required
|
||||
* `age`, optional
|
||||
|
||||
And then they declare other fields with some differences (in this case only about the `id`).
|
||||
And then they declare other fields with some differences (in this case, only about the `id`).
|
||||
|
||||
We want to **avoid duplicated information** if possible.
|
||||
|
||||
This is important if, for example, in the future we decide to **refactor the code** and rename one field (column). For example, from `secret_name` to `secret_identity`.
|
||||
This is important if, for example, in the future, we decide to **refactor the code** and rename one field (column). For example, from `secret_name` to `secret_identity`.
|
||||
|
||||
If we have that duplicated in multiple models, we could easily forget to update one of them. But if we **avoid duplication**, there's only one place that would need updating. ✨
|
||||
|
||||
@@ -305,6 +305,31 @@ And of course, all these fields will be in the columns for the resulting `hero`
|
||||
|
||||
And those inherited fields will also be in the **autocompletion** and **inline errors** in editors, etc.
|
||||
|
||||
### Columns and Inheritance with Multiple Models
|
||||
|
||||
Notice that the parent model `HeroBase` is not a **table model**, but still, we can declare `name` and `age` using `Field(index=True)`.
|
||||
|
||||
```Python hl_lines="4 6 9"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/fastapi/multiple_models/tutorial002.py[ln:7-14]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python
|
||||
{!./docs_src/tutorial/fastapi/multiple_models/tutorial002.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
This won't affect this parent **data model** `HeroBase`.
|
||||
|
||||
But once the child model `Hero` (the actual **table model**) inherits those fields, it will use those field configurations to create the indexes when creating the tables in the database.
|
||||
|
||||
### The `HeroCreate` **Data Model**
|
||||
|
||||
Now let's see the `HeroCreate` model that will be used to define the data that we want to receive in the API when creating a new hero.
|
||||
@@ -336,9 +361,9 @@ And because we can't leave the empty space when creating a new class, but we don
|
||||
|
||||
This means that there's nothing else special in this class apart from the fact that it is named `HeroCreate` and that it inherits from `HeroBase`.
|
||||
|
||||
As an alternative, we could use `HeroBase` directly in the API code instead of `HeroCreate`, but it would show up in the auomatic docs UI with that name "`HeroBase`" which could be **confusing** for clients. Instead, "`HeroCreate`" is a bit more explicit about what it is for.
|
||||
As an alternative, we could use `HeroBase` directly in the API code instead of `HeroCreate`, but it would show up in the automatic docs UI with that name "`HeroBase`" which could be **confusing** for clients. Instead, "`HeroCreate`" is a bit more explicit about what it is for.
|
||||
|
||||
On top of that, we could easily decide in the future that we want to receive **more data** when creating a new hero apart from the data in `HeroBase` (for example a password), and now we already have the class to put those extra fields.
|
||||
On top of that, we could easily decide in the future that we want to receive **more data** when creating a new hero apart from the data in `HeroBase` (for example, a password), and now we already have the class to put those extra fields.
|
||||
|
||||
### The `HeroRead` **Data Model**
|
||||
|
||||
@@ -365,7 +390,7 @@ This one just declares that the `id` field is required when reading a hero from
|
||||
|
||||
## Review the Updated Docs UI
|
||||
|
||||
The FastAPI code is still the same as above, we still use `Hero`, `HeroCreate`, and `HeroRead`. But now we define them in a smarter way with inheritance.
|
||||
The FastAPI code is still the same as above, we still use `Hero`, `HeroCreate`, and `HeroRead`. But now, we define them in a smarter way with inheritance.
|
||||
|
||||
So, we can jump to the docs UI right away and see how they look with the updated data.
|
||||
|
||||
@@ -375,7 +400,7 @@ Let's see the new UI for creating a hero:
|
||||
|
||||
<img class="shadow" alt="Interactive API docs UI" src="/img/tutorial/fastapi/multiple-models/image02.png">
|
||||
|
||||
Nice! It now shows that to create a hero, we just pass the `name`, `secret_name`, and optinally `age`.
|
||||
Nice! It now shows that to create a hero, we just pass the `name`, `secret_name`, and optionally `age`.
|
||||
|
||||
We no longer pass an `id`.
|
||||
|
||||
@@ -391,7 +416,7 @@ And if we check the schema for the **Read Heroes** *path operation* it will also
|
||||
|
||||
## Inheritance and Table Models
|
||||
|
||||
We just saw how powerful inheritance of these models can be.
|
||||
We just saw how powerful the inheritance of these models could be.
|
||||
|
||||
This is a very simple example, and it might look a bit... meh. 😅
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ But if the integer is not the ID of any hero in the database, it will not find a
|
||||
|
||||
So, we check it in an `if` block, if it's `None`, we raise an `HTTPException` with a `404` status code.
|
||||
|
||||
And to use it we first import `HTTPException` from `fastapi`.
|
||||
And to use it, we first import `HTTPException` from `fastapi`.
|
||||
|
||||
This will let the client know that they probably made a mistake on their side and requested a hero that doesn't exist in the database.
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ And the same way, we declared the `TeamRead` with only the same base fields of t
|
||||
|
||||
# Code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-37]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-36]!}
|
||||
|
||||
# Code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:46-47]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:45-46]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -80,11 +80,11 @@ In this case, we used `response_model=TeamRead` and `response_model=HeroRead`, s
|
||||
```Python hl_lines="3 8 12 17"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:105-110]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:104-109]!}
|
||||
|
||||
# Code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:160-165]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:158-163]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -102,7 +102,7 @@ In this case, we used `response_model=TeamRead` and `response_model=HeroRead`, s
|
||||
|
||||
Now let's stop for a second and think about it.
|
||||
|
||||
We cannot simply include *all* the data including all the internal relationships, because each **hero** has an attribute `team` with their team, and then that **team** also has an attribute `heroes` with all the **heroes** in the team, including this one.
|
||||
We cannot simply include *all* the data, including all the internal relationships, because each **hero** has an attribute `team` with their team, and then that **team** also has an attribute `heroes` with all the **heroes** in the team, including this one.
|
||||
|
||||
If we tried to include everything, we could make the server application **crash** trying to extract **infinite data**, going through the same hero and team over and over again internally, something like this:
|
||||
|
||||
@@ -152,7 +152,7 @@ If we tried to include everything, we could make the server application **crash*
|
||||
}
|
||||
```
|
||||
|
||||
As you can see, in this example we would get the hero **Rusty-Man**, and from this hero we would get the team **Preventers**, and then from this team we would get its heroes, of course, including **Rusty-Man**... 😱
|
||||
As you can see, in this example, we would get the hero **Rusty-Man**, and from this hero we would get the team **Preventers**, and then from this team we would get its heroes, of course, including **Rusty-Man**... 😱
|
||||
|
||||
So we start again, and in the end, the server would just crash trying to get all the data with a `"Maximum recursion error"`, we would not even get a response like the one above.
|
||||
|
||||
@@ -164,7 +164,7 @@ This is a decision that will depend on **each application**.
|
||||
|
||||
In our case, let's say that if we get a **list of heroes**, we don't want to also include each of their teams in each one.
|
||||
|
||||
And if we get a **list of teams**, we don't want to get a a list of the heroes for each one.
|
||||
And if we get a **list of teams**, we don't want to get a list of the heroes for each one.
|
||||
|
||||
But if we get a **single hero**, we want to include the team data (without the team's heroes).
|
||||
|
||||
@@ -195,7 +195,7 @@ We'll add them **after** the other models so that we can easily reference the pr
|
||||
|
||||
</details>
|
||||
|
||||
These two models are very **simple in code**, but there's a lot happening here, let's check it out.
|
||||
These two models are very **simple in code**, but there's a lot happening here. Let's check it out.
|
||||
|
||||
### Inheritance and Type Annotations
|
||||
|
||||
@@ -203,7 +203,7 @@ The `HeroReadWithTeam` **inherits** from `HeroRead`, which means that it will ha
|
||||
|
||||
And then it adds the **new field** `team`, which could be `None`, and is declared with the type `TeamRead` with the base fields for reading a team.
|
||||
|
||||
Then we do the same for the `TeamReadWithHeroes`, it **inherits** from `TeamRead`, and declare the **new field** `heroes` which is a list of `HeroRead`.
|
||||
Then we do the same for the `TeamReadWithHeroes`, it **inherits** from `TeamRead`, and declares the **new field** `heroes`, which is a list of `HeroRead`.
|
||||
|
||||
### Data Models Without Relationship Attributes
|
||||
|
||||
@@ -213,7 +213,7 @@ Instead, here these are only **data models** that will tell FastAPI **which attr
|
||||
|
||||
### Reference to Other Models
|
||||
|
||||
Also notice that the field `team` is not declared with this new `TeamReadWithHeroes`, because that would again create that infinite recursion of data. Instead, we declare it with the normal `TeamRead` model.
|
||||
Also, notice that the field `team` is not declared with this new `TeamReadWithHeroes`, because that would again create that infinite recursion of data. Instead, we declare it with the normal `TeamRead` model.
|
||||
|
||||
And the same for `TeamReadWithHeroes`, the model used for the new field `heroes` uses `HeroRead` to get only each hero's data.
|
||||
|
||||
@@ -234,7 +234,7 @@ In the case of the hero, this tells FastAPI to extract the `team` too. And in th
|
||||
|
||||
# Code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/fastapi/relationships/tutorial001.py[ln:168-173]!}
|
||||
{!./docs_src/tutorial/fastapi/relationships/tutorial001.py[ln:167-172]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -326,7 +326,7 @@ Now we get the list of **heroes** included:
|
||||
|
||||
## Recap
|
||||
|
||||
Using the same techniques to declare additonal **data models** we can tell FastAPI what data to return in the responses, even when we return **table models**.
|
||||
Using the same techniques to declare additional **data models**, we can tell FastAPI what data to return in the responses, even when we return **table models**.
|
||||
|
||||
Here we almost **didn't have to change the FastAPI app** code, but of course, there will be cases where you need to get the data and process it in different ways in the *path operation function* before returning it.
|
||||
|
||||
@@ -334,4 +334,4 @@ But even in those cases, you will be able to define the **data models** to use i
|
||||
|
||||
By this point, you already have a very robust API to handle data in a SQL database combining **SQLModel** with **FastAPI**, and implementing **best practices**, like data validation, conversion, filtering, and documentation. ✨
|
||||
|
||||
In the next chapter I'll tell you how to implement automated **testing** for your application using FastAPI and SQLModel. ✅
|
||||
In the next chapter, I'll tell you how to implement automated **testing** for your application using FastAPI and SQLModel. ✅
|
||||
|
||||
@@ -22,7 +22,7 @@ You can see that there's a possible "Successful Response" with a code `200`, but
|
||||
|
||||
<img class="shadow" alt="API docs UI without response data schemas" src="/img/tutorial/fastapi/response-model/image01.png">
|
||||
|
||||
Right now we only tell FastAPI the data we want to receive, but we don't tell it yet the data we want to send back.
|
||||
Right now, we only tell FastAPI the data we want to receive, but we don't tell it yet the data we want to send back.
|
||||
|
||||
Let's do that now. 🤓
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ We import `Depends()` from `fastapi`. Then we use it in the *path operation func
|
||||
|
||||
You can read more about it in the FastAPI documentation <a href="https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#order-the-parameters-as-you-need-tricks" class="external-link" target="_blank">Path Parameters and Numeric Validations - Order the parameters as you need, tricks</a>
|
||||
|
||||
The value of a dependency will **only be used for one request**, FastAPI will call it right before calling your code, and will give you the value from that dependency.
|
||||
The value of a dependency will **only be used for one request**, FastAPI will call it right before calling your code and will give you the value from that dependency.
|
||||
|
||||
If it had `yield`, then it will continue the rest of the execution once you are done sending the response. In the case of the **session**, it will finish the cleanup code from the `with` block, closing the session, etc.
|
||||
|
||||
@@ -177,7 +177,7 @@ And then we remove the previous `with` block with the old **session**.
|
||||
|
||||
# Code here omitted 👈
|
||||
|
||||
{!./docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py[ln:55-107]!}
|
||||
{!./docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py[ln:55-106]!}
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
@@ -23,7 +23,7 @@ $ python -m pip install fastapi "uvicorn[standard]"
|
||||
```
|
||||
|
||||
</div>
|
||||
s
|
||||
|
||||
## **SQLModel** Code - Models, Engine
|
||||
|
||||
Now let's start with the SQLModel code.
|
||||
@@ -152,13 +152,13 @@ It will be called when a user sends a request with a `POST` **operation** to the
|
||||
|
||||
## The **SQLModel** Advantage
|
||||
|
||||
Here's where having our **SQLModel** class models be both **SQLAlchemy** models and **Pydantic** models at the same tieme shine. ✨
|
||||
Here's where having our **SQLModel** class models be both **SQLAlchemy** models and **Pydantic** models at the same time shine. ✨
|
||||
|
||||
Here we use the **same** class model to define the **request body** that will be received by our API.
|
||||
|
||||
Because **FastAPI** is based on Pydantic, it will use the same model (the Pydantic part) to do automatic data validation and <abbr title="also called serialization, marshalling">conversion</abbr> from the JSON request to an object that is an actual instance of the `Hero` class.
|
||||
|
||||
And then because this same **SQLModel** object is not only a **Pydantic** model instance but also a **SQLAlchemy** model instance, we can use it directly in a **session** to create the row in the database.
|
||||
And then, because this same **SQLModel** object is not only a **Pydantic** model instance but also a **SQLAlchemy** model instance, we can use it directly in a **session** to create the row in the database.
|
||||
|
||||
So we can use intuitive standard Python **type annotations**, and we don't have to duplicate a lot of the code for the database models and the API data models. 🎉
|
||||
|
||||
@@ -190,13 +190,13 @@ When a client sends a request to the **path** `/heroes/` with a `GET` HTTP **ope
|
||||
|
||||
## One Session per Request
|
||||
|
||||
Remember that we shoud use a SQLModel **session** per each group of operations and if we need other unrelated operations we should use a different session?
|
||||
Remember that we should use a SQLModel **session** per each group of operations and if we need other unrelated operations we should use a different session?
|
||||
|
||||
Here it is much more obvious.
|
||||
|
||||
We should normally have **one session per request** in most of the cases.
|
||||
|
||||
In some isolated cases we would want to have new sessions inside, so, **more than one session** per request.
|
||||
In some isolated cases, we would want to have new sessions inside, so, **more than one session** per request.
|
||||
|
||||
But we would **never want to *share* the same session** among different requests.
|
||||
|
||||
@@ -277,7 +277,7 @@ And then you can get them back with the **Read Heroes** *path operation*:
|
||||
|
||||
Now you can terminate that Uvicorn server by going back to the terminal and pressing <kbd>Ctrl+C</kbd>.
|
||||
|
||||
And then you can open **DB Browser for SQLite** and check the database, to explore the data and confirm that it indeed saved the heroes. 🎉
|
||||
And then, you can open **DB Browser for SQLite** and check the database, to explore the data and confirm that it indeed saved the heroes. 🎉
|
||||
|
||||
<img class="shadow" alt="DB Browser for SQLite showing the heroes" src="/img/tutorial/fastapi/simple-hero-api/db-browser-01.png">
|
||||
|
||||
@@ -287,4 +287,4 @@ Good job! This is already a FastAPI **web API** application to interact with the
|
||||
|
||||
There are several things we can improve and extend. For example, we want the database to decide the ID of each new hero, we don't want to allow a user to send it.
|
||||
|
||||
We will do all those improvements in the next chapters. 🚀
|
||||
We will make all those improvements in the next chapters. 🚀
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# FastAPI Path Opeartions for Teams - Other Models
|
||||
# FastAPI Path Operations for Teams - Other Models
|
||||
|
||||
Let's now update the **FastAPI** application to handle data for teams.
|
||||
|
||||
@@ -12,14 +12,14 @@ Let's add the models for the teams.
|
||||
|
||||
It's the same process we did for heroes, with a base model, a **table model**, and some other **data models**.
|
||||
|
||||
We have a `TeamBase` **data model**, and from it we inherit with a `Team` **table model**.
|
||||
We have a `TeamBase` **data model**, and from it, we inherit with a `Team` **table model**.
|
||||
|
||||
Then we also inherit from the `TeamBase` for the `TeamCreate` and `TeamRead` **data models**.
|
||||
|
||||
And we also create a `TeamUpdate` **data model**.
|
||||
|
||||
```Python hl_lines="7-9 12-15 18-19 22-23 26-29"
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-29]!}
|
||||
```Python hl_lines="7-9 12-15 18-19 22-23 26-28"
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:1-28]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -42,7 +42,7 @@ Let's now update the `Hero` models too.
|
||||
```Python hl_lines="3-8 11-15 17-18 21-22 25-29"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:32-58]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:31-57]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -66,10 +66,10 @@ And even though the `HeroBase` is *not* a **table model**, we can declare `team_
|
||||
|
||||
Notice that the **relationship attributes**, the ones with `Relationship()`, are **only** in the **table models**, as those are the ones that are handled by **SQLModel** with SQLAlchemy and that can have the automatic fetching of data from the database when we access them.
|
||||
|
||||
```Python hl_lines="11 39"
|
||||
```Python hl_lines="11 38"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-58]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:7-57]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -92,7 +92,7 @@ These are equivalent and very similar to the **path operations** for the **heroe
|
||||
```Python hl_lines="3-9 12-20 23-28 31-47 50-57"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:140-194]!}
|
||||
{!./docs_src/tutorial/fastapi/teams/tutorial001.py[ln:138-192]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
@@ -108,9 +108,9 @@ These are equivalent and very similar to the **path operations** for the **heroe
|
||||
|
||||
## Using Relationships Attributes
|
||||
|
||||
Up to this point we are actually not using the **relationship attributes**, but we could access them in our code.
|
||||
Up to this point, we are actually not using the **relationship attributes**, but we could access them in our code.
|
||||
|
||||
In the next chapter we will play more with them.
|
||||
In the next chapter, we will play more with them.
|
||||
|
||||
## Check the Docs UI
|
||||
|
||||
|
||||
@@ -76,13 +76,13 @@ Let's start with a simple test, with just the basic test code we need the check
|
||||
|
||||
That's the **core** of the code we need for all the tests later.
|
||||
|
||||
But now we need to deal with a bit of logistics and details we are not paying attention to just yet. 🤓
|
||||
But now, we need to deal with a bit of logistics and details we are not paying attention to just yet. 🤓
|
||||
|
||||
## Testing Database
|
||||
|
||||
This test looks fine, but there's a problem.
|
||||
|
||||
If we run it, it will use the same **production database** that we are using to store our very important **heroes**, and we will end up adding adding unnecesary data to it, or even worse, in future tests we could end up removing production data.
|
||||
If we run it, it will use the same **production database** that we are using to store our very important **heroes**, and we will end up adding unnecessary data to it, or even worse, in future tests we could end up removing production data.
|
||||
|
||||
So, we should use an independent **testing database**, just for the tests.
|
||||
|
||||
@@ -155,7 +155,7 @@ That way, when we call `.create_all()` all the **table models** are correctly re
|
||||
|
||||
## Memory Database
|
||||
|
||||
Now we are not using the production database, instead we use a **new testing database** with the `testing.db` file, which is great.
|
||||
Now we are not using the production database. Instead, we use a **new testing database** with the `testing.db` file, which is great.
|
||||
|
||||
But SQLite also supports having an **in memory** database. This means that all the database is only in memory, and it is never saved in a file on disk.
|
||||
|
||||
@@ -171,7 +171,7 @@ Other alternatives and ideas 👀
|
||||
</summary>
|
||||
Before arriving at the idea of using an **in-memory database** we could have explored other alternatives and ideas.
|
||||
|
||||
The first, is that we are not deleting the file after we finish the test, so, the next test could have **leftover data**. So, the right thing would be to delete the file right after finishing the test. 🔥
|
||||
The first is that we are not deleting the file after we finish the test, so the next test could have **leftover data**. So, the right thing would be to delete the file right after finishing the test. 🔥
|
||||
|
||||
But if each test has to create a new file and then delete it afterwards, running all the tests could be **a bit slow**.
|
||||
|
||||
@@ -179,7 +179,7 @@ Right now, we have a file `testing.db` that is used by all the tests (we only ha
|
||||
|
||||
So, if we tried to run the tests at the same time **in parallel** to try to speed things up a bit, they would clash trying to use the *same* `testing.db` file.
|
||||
|
||||
Of couse, we could also fix that, using some **random name** for each testing database file... but in the case of SQLite, we have an even better alternative with just using an **in-memory database**. ✨
|
||||
Of course, we could also fix that, using some **random name** for each testing database file... but in the case of SQLite, we have an even better alternative by just using an **in-memory database**. ✨
|
||||
|
||||
</details>
|
||||
|
||||
@@ -208,7 +208,7 @@ And all the other tests can do the same.
|
||||
|
||||
Great, that works, and you could replicate all that process in each of the test functions.
|
||||
|
||||
But we had to add a lot of **boilerplate code** to handle the custom database, creating it in memory, the custom session, the dependency override.
|
||||
But we had to add a lot of **boilerplate code** to handle the custom database, creating it in memory, the custom session, and the dependency override.
|
||||
|
||||
Do we really have to duplicate all that for **each test**? No, we can do better! 😎
|
||||
|
||||
@@ -242,12 +242,12 @@ Let's see the first code example with a fixture:
|
||||
|
||||
**pytest** fixtures work in a very similar way to FastAPI dependencies, but have some minor differences:
|
||||
|
||||
* In pytest fixtures we need to add a decorator of `@pytest.fixture()` on top.
|
||||
* In pytest fixtures, we need to add a decorator of `@pytest.fixture()` on top.
|
||||
* To use a pytest fixture in a function, we have to declare the parameter with the **exact same name**. In FastAPI we have to **explicitly use `Depends()`** with the actual function inside it.
|
||||
|
||||
But apart from the way we declare them and how we tell the framework that we want to have them in the function, they **work in a very similar way**.
|
||||
|
||||
Now we create lot's of tests, and re-use that same fixture in all of them, saving us that **boilerplate code**.
|
||||
Now we create lot's of tests and re-use that same fixture in all of them, saving us that **boilerplate code**.
|
||||
|
||||
**pytest** will make sure to run them right before (and finish them right after) each test function. So, each test function will actually have its own database, engine, and session.
|
||||
|
||||
@@ -255,7 +255,7 @@ Now we create lot's of tests, and re-use that same fixture in all of them, savin
|
||||
|
||||
Awesome, that fixture helps us prevent a lot of duplicated code.
|
||||
|
||||
But currently we still have to write some code in the test function that will be repetitive for other tests, right now we:
|
||||
But currently, we still have to write some code in the test function that will be repetitive for other tests, right now we:
|
||||
|
||||
* create the **dependency override**
|
||||
* put it in the `app.dependency_overrides`
|
||||
@@ -277,7 +277,7 @@ So, we can create a **client fixture** that will be used in all the tests, and i
|
||||
!!! tip
|
||||
Check out the number bubbles to see what is done by each line of code.
|
||||
|
||||
Now we have a **client fixture** that in turns uses the **session fixture**.
|
||||
Now we have a **client fixture** that, in turn, uses the **session fixture**.
|
||||
|
||||
And in the actual test function, we just have to declare that we require this **client fixture**.
|
||||
|
||||
@@ -285,7 +285,7 @@ And in the actual test function, we just have to declare that we require this **
|
||||
|
||||
At this point, it all might seem like we just did a lot of changes for nothing, to get **the same result**. 🤔
|
||||
|
||||
But normally we will create **lots of other test functions**. And now all the boilerplate and complexity is **writen only once**, in those two fixtures.
|
||||
But normally we will create **lots of other test functions**. And now all the boilerplate and complexity is **written only once**, in those two fixtures.
|
||||
|
||||
Let's add some more tests:
|
||||
|
||||
@@ -311,13 +311,13 @@ Let's add some more tests:
|
||||
|
||||
That's why we add these two extra tests here.
|
||||
|
||||
Now, any additional test functions can be as **simple** as the first one, they just have to **declate the `client` parameter** to get the `TestClient` **fixture** with all the database stuff setup. Nice! 😎
|
||||
Now, any additional test functions can be as **simple** as the first one, they just have to **declare the `client` parameter** to get the `TestClient` **fixture** with all the database stuff setup. Nice! 😎
|
||||
|
||||
## Why Two Fixtures
|
||||
|
||||
Now, seeing the code we could think, why do we put **two fixtures** instead of **just one** with all the code? And that makes total sense!
|
||||
Now, seeing the code, we could think, why do we put **two fixtures** instead of **just one** with all the code? And that makes total sense!
|
||||
|
||||
For these examples, **that would have been simpler**, there's no need to separate that code in two fixtures for them...
|
||||
For these examples, **that would have been simpler**, there's no need to separate that code into two fixtures for them...
|
||||
|
||||
But for the next test function, we will require **both fixtures**, the **client** and the **session**.
|
||||
|
||||
@@ -340,7 +340,7 @@ But for the next test function, we will require **both fixtures**, the **client*
|
||||
|
||||
</details>
|
||||
|
||||
In this test function we want to check that the *path operation* to **read a list of heroes** actually sends us heroes.
|
||||
In this test function, we want to check that the *path operation* to **read a list of heroes** actually sends us heroes.
|
||||
|
||||
But if the **database is empty**, we would get an **empty list**, and we wouldn't know if the hero data is being sent correctly or not.
|
||||
|
||||
@@ -362,7 +362,7 @@ The function for the **client fixture** and the actual testing function will **b
|
||||
|
||||
## Add the Rest of the Tests
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
```Python hl_lines="3 18 33"
|
||||
# Code above omitted 👆
|
||||
@@ -406,9 +406,9 @@ project/test_main.py <font color="#A6E22E">....... [100%]</font>
|
||||
|
||||
Did you read all that? Wow, I'm impressed! 😎
|
||||
|
||||
Adding tests to your application will give you a lot of **certainty** that everything is **working correctly**, as you indended.
|
||||
Adding tests to your application will give you a lot of **certainty** that everything is **working correctly**, as you intended.
|
||||
|
||||
And tests will be notoriously useful when **refactoring** your code, **changing things**, **adding features**. Because tests they can help catch a lot of errors that can be easily introduced by refactoring.
|
||||
And tests will be notoriously useful when **refactoring** your code, **changing things**, **adding features**. Because tests can help catch a lot of errors that can be easily introduced by refactoring.
|
||||
|
||||
And they will give you the confidence to work faster and **more efficiently**, because you know that you are checking if you are **not breaking anything**. 😅
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Now let's see how to update data in the database with a **FastAPI** *path operat
|
||||
|
||||
## `HeroUpdate` Model
|
||||
|
||||
We want clients to be able to udpate the `name`, the `secret_name`, and the `age` of a hero.
|
||||
We want clients to be able to update the `name`, the `secret_name`, and the `age` of a hero.
|
||||
|
||||
But we don't want them to have to include all the data again just to **update a single field**.
|
||||
|
||||
@@ -61,7 +61,7 @@ We will use a `PATCH` HTTP operation. This is used to **partially update data**,
|
||||
|
||||
</details>
|
||||
|
||||
We also read the `hero_id` from the *path parameter* an the request body, a `HeroUpdate`.
|
||||
We also read the `hero_id` from the *path parameter* and the request body, a `HeroUpdate`.
|
||||
|
||||
### Read the Existing Hero
|
||||
|
||||
@@ -100,7 +100,7 @@ But that also means that if we just call `hero.dict()` we will get a dictionary
|
||||
}
|
||||
```
|
||||
|
||||
And then if we update the hero in the database with this data, we would be removing any existing values, and that's probably **not what the client intended**.
|
||||
And then, if we update the hero in the database with this data, we would be removing any existing values, and that's probably **not what the client intended**.
|
||||
|
||||
But fortunately Pydantic models (and so SQLModel models) have a parameter we can pass to the `.dict()` method for that: `exclude_unset=True`.
|
||||
|
||||
@@ -200,7 +200,7 @@ We are **not simply omitting** the data that has the **default values**.
|
||||
|
||||
And we are **not simply omitting** anything that is `None`.
|
||||
|
||||
This means that, if a model in the database **has a value different than the default**, the client could **reset it to the same value as the default**, or even `None`, and we would **still notice it** and **update it accordingly**. 🤯🚀
|
||||
This means that if a model in the database **has a value different than the default**, the client could **reset it to the same value as the default**, or even `None`, and we would **still notice it** and **update it accordingly**. 🤯🚀
|
||||
|
||||
So, if the client wanted to intentionally remove the `age` of a hero, they could just send a JSON with:
|
||||
|
||||
@@ -218,11 +218,11 @@ And when getting the data with `hero.dict(exclude_unset=True)`, we would get:
|
||||
}
|
||||
```
|
||||
|
||||
So, we would use that value and upate the `age` to `None` in the database, **just as the client intended**.
|
||||
So, we would use that value and update the `age` to `None` in the database, **just as the client intended**.
|
||||
|
||||
Notice that `age` here is `None`, and **we still detected it**.
|
||||
|
||||
Also that `name` was not even sent, and we don't *accidentaly* set it to `None` or something, we just didn't touch it, because the client didn't sent it, so we are **pefectly fine**, even in these corner cases. ✨
|
||||
Also, that `name` was not even sent, and we don't *accidentally* set it to `None` or something. We just didn't touch it because the client didn't send it, so we are **perfectly fine**, even in these corner cases. ✨
|
||||
|
||||
These are some of the advantages of Pydantic, that we can use with SQLModel. 🎉
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
## Type hints
|
||||
|
||||
If you need a refreshed about how to use Python type hints (type annotations), check <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">FastAPI's Python types intro</a>.
|
||||
If you need a refresher about how to use Python type hints (type annotations), check <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">FastAPI's Python types intro</a>.
|
||||
|
||||
You can also check the <a href="https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html" class="external-link" target="_blank">mypy cheat sheet</a>.
|
||||
|
||||
**SQLModel** uses type annotations for everything, this way you can use a familiar Python syntax and get all the editor support posible, with autocompletion and in-editor error checking.
|
||||
**SQLModel** uses type annotations for everything, this way you can use a familiar Python syntax and get all the editor support possible, with autocompletion and in-editor error checking.
|
||||
|
||||
## Intro
|
||||
|
||||
@@ -64,15 +64,13 @@ $ cd sqlmodel-tutorial
|
||||
|
||||
Make sure you have an officially supported version of Python.
|
||||
|
||||
Currently it is **Python 3.6** and above (Python 3.5 was already deprecated).
|
||||
|
||||
You can check which version you have with:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python3 --version
|
||||
Python 3.6.9
|
||||
Python 3.11
|
||||
```
|
||||
|
||||
</div>
|
||||
@@ -84,8 +82,6 @@ You might want to try with the specific versions, for example with:
|
||||
* `python3.10`
|
||||
* `python3.9`
|
||||
* `python3.8`
|
||||
* `python3.7`
|
||||
* `python3.6`
|
||||
|
||||
The code would look like this:
|
||||
|
||||
@@ -97,7 +93,7 @@ $ python3 --version
|
||||
// This is too old! 😱
|
||||
Python 3.5.6
|
||||
// Let's see if python3.10 is available
|
||||
$ python3.10 --verson
|
||||
$ python3.10 --version
|
||||
// Oh, no, this one is not available 😔
|
||||
command not found: python3.10
|
||||
$ python3.9 --version
|
||||
@@ -136,10 +132,10 @@ Here are the commands you could use:
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
// Remember that you might need to use python3.9 or similar 💡
|
||||
// Remember that you might need to use python3.9 or similar 💡
|
||||
// Create the virtual environment using the module "venv"
|
||||
$ python3 -m venv env
|
||||
// ...here it creates the virtual enviroment in the directory "env"
|
||||
// ...here it creates the virtual environment in the directory "env"
|
||||
// Activate the virtual environment
|
||||
$ source ./env/bin/activate
|
||||
// Verify that the virtual environment is active
|
||||
@@ -161,7 +157,7 @@ Here are the commands you could use:
|
||||
```console
|
||||
// Create the virtual environment using the module "venv"
|
||||
# >$ python3 -m venv env
|
||||
// ...here it creates the virtual enviroment in the directory "env"
|
||||
// ...here it creates the virtual environment in the directory "env"
|
||||
// Activate the virtual environment
|
||||
# >$ .\env\Scripts\Activate.ps1
|
||||
// Verify that the virtual environment is active
|
||||
|
||||
406
docs/tutorial/indexes.md
Normal file
@@ -0,0 +1,406 @@
|
||||
# Indexes - Optimize Queries
|
||||
|
||||
We just saw how to get some data `WHERE` a **condition** is true. For example, where the hero **name is "Deadpond"**.
|
||||
|
||||
If we just create the tables and the data as we have been doing, when we `SELECT` some data using `WHERE`, the database would have to **scan** through **each one of the records** to find the ones that **match**. This is not a problem with 3 heroes as in these examples.
|
||||
|
||||
But imagine that your database has **thousands** or **millions** of **records**, if every time you want to find the heroes with the name "Deadpond" it has to scan through **all** of the records to find all the possible matches, then that becomes problematic, as it would be too slow.
|
||||
|
||||
I'll show you how to handle it with a database **index**.
|
||||
|
||||
The change in the code is **extremely small**, but it's useful to understand what's happening behind the scenes, so I'll show you **how it all works** and what it means.
|
||||
|
||||
---
|
||||
|
||||
If you already executed the previous examples and have a database with data, **remove the database file** before running each example, that way you won't have duplicate data and you will be able to get the same results.
|
||||
|
||||
## No Time to Explain
|
||||
|
||||
Are you already a **SQL expert** and don't have time for all my explanations?
|
||||
|
||||
Fine, in that case, you can **sneak peek** the final code to create indexes here.
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python hl_lines="8 10"
|
||||
{!./docs_src/tutorial/indexes/tutorial002.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
..but if you are not an expert, **continue reading**, this will probably be useful. 🤓
|
||||
|
||||
## What is an Index
|
||||
|
||||
In general, an **index** is just something we can have to help us **find things faster**. It normally works by having things in **order**. Let's think about some real-life examples before even thinking about databases and code.
|
||||
|
||||
### An Index and a Dictionary
|
||||
|
||||
Imagine a **dictionary**, a book with definitions of words. 📔 ...not a Python `dict`. 😅
|
||||
|
||||
Let's say that you want to **find a word**, for example the word "**database**". You take the dictionary, and open it somewhere, for example in the middle. Maybe you see some definitions of words that start with `m`, like `manual`, so you conclude that you are in the letter `m` in the dictionary.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary001.svg">
|
||||
|
||||
You know that in the alphabet, the letter `d` for `database` comes **before** the letter `m` for `manual`.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary002.svg">
|
||||
|
||||
So, you know you have to search in the dictionary **before** the point you currently are. You still don't know where the word `database` is, because you don't know exactly where the letter `d` is in the dictionary, but you know that **it is not after** that point, you can now **discard the right half** of the dictionary in your search.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary003.svg">
|
||||
|
||||
Next, you **open the dictionary again**, but only taking into account the **half of the dictionary** that can contain the word you want, the **left part of the dictionary**. You open it in the middle of that left part and now you arrive maybe at the letter `f`.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary004.svg">
|
||||
|
||||
You know that `d` from `database` comes before `f`. So it has to be **before** that. But now you know that `database` **is not after** that point, and you can discard the dictionary from that point onward.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary005.svg">
|
||||
|
||||
Now you have a **small section of dictionary** to search (only a **quarter** of dictionary can have your word). You take that **quarter** of the pages at the start of the dictionary that can contain your word, and open it in the middle of that section. Maybe you arrive at the letter `c`.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary006.svg">
|
||||
|
||||
You know the word `database` has to be **after** that and **not before** that point, so you can discard the left part of that block of pages.
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary007.svg">
|
||||
|
||||
You repeat this process **a few more times**, and you finally arrive at the letter `d`, you continue with the same process in that section for the letter `d` and you finally **find the word** `database`. 🎉
|
||||
|
||||
<img src="/img/tutorial/indexes/dictionary008.svg">
|
||||
|
||||
You had to open the dictionary a few times, maybe **5 or 10**. That's actually **very little work** compared to what it could have been.
|
||||
|
||||
!!! note "Technical Details"
|
||||
Do you like **fancy words**? Cool! Programmers tend to like fancy words. 😅
|
||||
|
||||
That <abbr title="a recipe, a sequence of predefined steps that achieve a result">algorithm</abbr> I showed you above is called **Binary Search**.
|
||||
|
||||
It's called like that because you **search** something by splitting the dictionary (or any ordered list of things) in **two** ("binary" means "two") parts. And you do that process multiple times until you find what you want.
|
||||
|
||||
### An Index and a Novel
|
||||
|
||||
Let's now imagine you are reading a **novel book**. And someone told you that at some point, they mention a **database**, and you want to find that chapter.
|
||||
|
||||
How do you find the word "*database*" there? You might have to read **the entire book** to find where the word "*database*" is located in the book. So, instead of opening the book 5 or 10 times, you would have to open each of the **500 pages** and read them one by one until you find the word. You might enjoy the book, though. 😅
|
||||
|
||||
But if we are only interested in **quickly finding information** (as when working with SQL databases), then reading each of the 500 pages is **too inefficient** when there could be an option to open the book in 5 or 10 places and find what you're looking for.
|
||||
|
||||
### A Technical Book with an Index
|
||||
|
||||
Now let's imagine you are reading a technical book. For example, with several topics about programming. And there's a couple of sections where it talks about a **database**.
|
||||
|
||||
This book might have a **book index**: a section in the book that has some **names of topics covered** and the **page numbers** in the book where you can read about them. And the topic names are **sorted** in alphabetic order, pretty much like a dictionary (a book with words, as in the previous example).
|
||||
|
||||
In this case, you can open that book in the end (or in the beginning) to find the **book index** section, it would have only a few pages. And then, you can do the same process as with the **dictionary** example above.
|
||||
|
||||
Open the index, and after **5 or 10 steps**, quickly find the topic "**database**" with the page numbers where that is covered, for example "page 253 in Chapter 5". Now you used the dictionary technique to find the **topic**, and that topic gave you a **page number**.
|
||||
|
||||
Now you know that you need to find "**page 253**". But by looking at the closed book you still don't know where that page is, so you have to **find that page**. To find it, you can do the same process again, but this time, instead of searching for a **topic** in the **index**, you are searching for a **page number** in the **entire book**. And after **5 or 10 more steps**, you find the page 253 in Chapter 5.
|
||||
|
||||
<img src="/img/tutorial/indexes/techbook001.svg">
|
||||
|
||||
After this, even though this book is not a dictionary and has some particular content, you were able to **find the section** in the book that talks about a "**database**" in a **few steps** (say 10 or 20, instead of reading all the 500 pages).
|
||||
|
||||
The main point is that the index is **sorted**, so we can use the same process we used for the **dictionary** to find the topic. And then that gives us a page number, and the **page numbers are also sorted**! 😅
|
||||
|
||||
When we have a list of sorted things we can apply the same technique, and that's the whole trick here, we use the same technique first for the **topics** in the index and then for the **page numbers** to find the actual chapter.
|
||||
|
||||
Such efficiency! 😎
|
||||
|
||||
## What are Database Indexes
|
||||
|
||||
**Database indexes** are very similar to **book indexes**.
|
||||
|
||||
Database indexes store some info, some keys, in a way that makes it **easy and fast to find** (for example sorted), and then for each key they **point to some data somewhere else** in the database.
|
||||
|
||||
Let's see a more clear example. Let's say you have this table in a database:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>id</th><th>name</th><th>secret_name</th><th>age</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td><td>Deadpond</td><td>Dive Wilson</td><td>null</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td><td>Spider-Boy</td><td>Pedro Parqueador</td><td>null</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td><td>Rusty-Man</td><td>Tommy Sharp</td><td>48</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
And let's imagine you have **many more rows**, many more heroes. Probably **thousands**.
|
||||
|
||||
If you tell the SQL database to get you a hero by a specific name, for example `Spider-Boy` (by using the `name` in the `WHERE` part of the SQL query), the database will have to **scan** all the heroes, checking **one by one** to find all the ones with a name of `Spider-Boy`.
|
||||
|
||||
In this case, there's only one, but there's nothing limiting the database from having **more records with the same name**. And because of that, the database would **continue searching** and checking each one of the records, which would be very slow.
|
||||
|
||||
But now let's say that the database has an index for the column `name`. The index could look something like this, we could imagine that the index is like an additional special table that the database manages automatically:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>name</th><th>id</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Deadpond</td><td>1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rusty-Man</td><td>3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Spider-Boy</td><td>2</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
It would have each `name` field from the `hero` table **in order**. It would not be sorted by `id`, but by `name` (in alphabetical order, as the `name` is a string). So, first it would have `Deadpond`, then `Rusty-Man`, and last `Spider-Boy`. It would also include the `id` of each hero. Remember that this could have **thousands** of heroes.
|
||||
|
||||
Then the database would be able to use more or less the same ideas in the examples above with the **dictionary** and the **book index**.
|
||||
|
||||
It could start somewhere (for example, in the middle of the index). It could arrive at some hero there in the middle, like `Rusty-Man`. And because the **index** has the `name` fields in order, the database would know that it can **discard all the previous index rows** and **only search** in the following index rows.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>name</th><th>id</th>
|
||||
</tr>
|
||||
<tr style="background-color: #F5F5F5; color: #999999;">
|
||||
<td>Deadpond</td><td>1</td>
|
||||
</tr>
|
||||
<tr style="background-color: #F5F5F5; color: #999999;">
|
||||
<td>Rusty-Man</td><td>3</td>
|
||||
</tr>
|
||||
<tr style="background-color: #FFF2CC;">
|
||||
<td>Spider-Boy</td><td>2</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
And that way, as with the example with the dictionary above, **instead of reading thousands of heroes**, the database would be able to do a few steps, say **5 or 10 steps**, and arrive at the row of the index that has `Spider-Boy`, even if the table (and index) has thousands of rows:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>name</th><th>id</th>
|
||||
</tr>
|
||||
<tr style="background-color: #F5F5F5; color: #999999;">
|
||||
<td>Deadpond</td><td>1</td>
|
||||
</tr>
|
||||
<tr style="background-color: #F5F5F5; color: #999999;">
|
||||
<td>Rusty-Man</td><td>3</td>
|
||||
</tr>
|
||||
<tr style="background-color: #D5E8D4;">
|
||||
<td>✨ Spider-Boy ✨</td><td>2</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Then by looking at **this index row**, it would know that the `id` for `Spider-Boy` in the `hero` table is `2`.
|
||||
|
||||
So then it could **search that `id`** in the `hero` table using more or less the **same technique**.
|
||||
|
||||
That way, in the end, instead of reading thousands of records, the database only had to do **a few steps** to find the hero we wanted.
|
||||
|
||||
## Updating the Index
|
||||
|
||||
As you can imagine, for all this to work, the index would need to be **up to date** with the data in the database.
|
||||
|
||||
If you had to update it **manually** in code, it would be very cumbersome and **error-prone**, as it would be easy to end up in a state where the index is not up to date and points to incorrect data. 😱
|
||||
|
||||
Here's the good news: when you create an index in a **SQL Database**, the database takes care of **updating** it **automatically** whenever it's necessary. 😎🎉
|
||||
|
||||
If you **add new records** to the `hero` table, the database will **automatically** update the index. It will do the **same process** of **finding** the right place to put the new index data (those **5 or 10 steps** described above), and then it will save the new index information there. The same would happen when you **update** or **delete** data.
|
||||
|
||||
Defining and creating an index is very **easy** with SQL databases. And then **using it** is even easier... it's transparent. The database will figure out which index to use automatically, the SQL queries don't even change.
|
||||
|
||||
So, in SQL databases **indexes are great**! And are super **easy to use**. Why not just have indexes for everything? .....Because indexes also have a "**cost**" in computation and storage (disk space).
|
||||
|
||||
## Index Cost
|
||||
|
||||
There's a **cost** associated with **indexes**. 💰
|
||||
|
||||
When you don't have an index and add a **new row** to the table `hero`, the database has to perform **1 operation** to add the new hero row at the end of the table.
|
||||
|
||||
But if you have an **index** for the **hero names**, now the database has to perform the same **1 operation** to add that row **plus** some extra **5 or 10 operations** in the index, to find the right spot for the name, to then add that **index record** there.
|
||||
|
||||
And if you have an index for the `name`, one for the `age`, and one for the `secret_name`, now the database has to perform the same **1 operation** to add that row **plus** some extra **5 or 10 operations** in the index **times 3**, for each of the indexes. This means that now adding one row takes something like **31 operations**.
|
||||
|
||||
This also means that you are **exchanging** the time it takes to **read** data for the time it takes to **write** data plus some extra **space** in the database.
|
||||
|
||||
If you have queries that get data out of the database comparing each one of those fields (for example using `WHERE`), then it makes total sense to have indexes for each one of them. Because **31 operations** while creating or updating data (plus the space of the index) is much, much better than the possible **500 or 1000 operations** to read all the rows to be able to compare them using each field.
|
||||
|
||||
But if you **never** have queries that find records by the `secret_name` (you never use `secret_name` in the `WHERE` part) it probably doesn't make sense to have an index for the `secret_name` field/column, as that will increase the computational and space **cost** of writing and updating the database.
|
||||
|
||||
## Create an Index with SQL
|
||||
|
||||
Phew, that was a lot of theory and explanations. 😅
|
||||
|
||||
The most important thing about indexes is **understanding** them, how, and when to use them.
|
||||
|
||||
Let's now see the **SQL** syntax to create an **index**. It is very simple:
|
||||
|
||||
```SQL hl_lines="3"
|
||||
CREATE INDEX ix_hero_name
|
||||
ON hero (name)
|
||||
```
|
||||
|
||||
This means, more or less:
|
||||
|
||||
> Hey SQL database 👋, please `CREATE` an `INDEX` for me.
|
||||
>
|
||||
> I want the name of the index to be `ix_hero_name`.
|
||||
>
|
||||
> This index should be `ON` the table `hero`, it refers to that table.
|
||||
>
|
||||
> The column I want you to use for it is `name`.
|
||||
|
||||
## Declare Indexes with SQLModel
|
||||
|
||||
And now let's see how to define indexes in **SQLModel**.
|
||||
|
||||
The change in code is underwhelming, it's very simple. 😆
|
||||
|
||||
Here's the `Hero` model we had before:
|
||||
|
||||
```Python hl_lines="8"
|
||||
{!./docs_src/tutorial/where/tutorial001.py[ln:1-10]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python
|
||||
{!./docs_src/tutorial/where/tutorial001.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Let's now update it to tell **SQLModel** to create an index for the `name` field when creating the table:
|
||||
|
||||
```Python hl_lines="8"
|
||||
{!./docs_src/tutorial/indexes/tutorial001.py[ln:1-10]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python
|
||||
{!./docs_src/tutorial/indexes/tutorial001.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
We use the same `Field()` again as we did before, and set `index=True`. That's it! 🚀
|
||||
|
||||
Notice that we didn't set an argument of `default=None` or anything similar. This means that **SQLModel** (thanks to Pydantic) will keep it as a **required** field.
|
||||
|
||||
!!! info
|
||||
SQLModel (actually SQLAlchemy) will **automatically generate the index name** for you.
|
||||
|
||||
In this case the generated name would be `ix_hero_name`.
|
||||
|
||||
## Query Data
|
||||
|
||||
Now, to query the data using the field `name` and the new index we don't have to do anything special or different in the code, it's just **the same code**.
|
||||
|
||||
The SQL database will figure it out **automatically**. ✨
|
||||
|
||||
This is great because it means that indexes are very **simple to use**. But it might also feel counterintuitive at first, as you are **not doing anything** explicitly in the code to make it obvious that the index is useful, it all happens in the database behind the scenes.
|
||||
|
||||
```Python hl_lines="5"
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/indexes/tutorial001.py[ln:36-41]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python
|
||||
{!./docs_src/tutorial/indexes/tutorial001.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
This is exactly the same code as we had before, but now the database will **use the index** underneath.
|
||||
|
||||
## Run the Program
|
||||
|
||||
If you run the program now, you will see an output like this:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Some boilerplate output omitted 😉
|
||||
|
||||
// Create the table
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
// Create the index 🤓🎉
|
||||
CREATE INDEX ix_hero_name ON hero (name)
|
||||
|
||||
// The SELECT with WHERE looks the same
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.name = ?
|
||||
INFO Engine [no key 0.00014s] ('Deadpond',)
|
||||
|
||||
// The resulting hero
|
||||
secret_name='Dive Wilson' age=None id=1 name='Deadpond'
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## More Indexes
|
||||
|
||||
We are going to query the `hero` table doing comparisons on the `age` field too, so we should **define an index** for that one as well:
|
||||
|
||||
```Python hl_lines="10"
|
||||
{!./docs_src/tutorial/indexes/tutorial002.py[ln:1-10]!}
|
||||
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>👀 Full file preview</summary>
|
||||
|
||||
```Python
|
||||
{!./docs_src/tutorial/indexes/tutorial002.py!}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
In this case, we want the default value of `age` to continue being `None`, so we set `default=None` when using `Field()`.
|
||||
|
||||
Now when we use **SQLModel** to create the database and tables, it will also create the **indexes** for these two columns in the `hero` table.
|
||||
|
||||
So, when we query the database for the `hero` table and use those **two columns** to define what data we get, the database will be able to **use those indexes** to improve the **reading performance**. 🚀
|
||||
|
||||
## Primary Key and Indexes
|
||||
|
||||
You probably noticed that we didn't set `index=True` for the `id` field.
|
||||
|
||||
Because the `id` is already the **primary key**, the database will automatically create an internal **index** for it.
|
||||
|
||||
The database always creates an internal index for **primary keys** automatically, as those are the primary way to organize, store, and retrieve data. 🤓
|
||||
|
||||
But if you want to be **frequently querying** the SQL database for any **other field** (e.g. using any other field in the `WHERE` section), you will probably want to have at least an **index** for that.
|
||||
|
||||
## Recap
|
||||
|
||||
**Indexes** are very important to improve **reading performance** and speed when querying the database. 🏎
|
||||
|
||||
Creating and using them is very **simple** and easy. The most important part is to understand **how** they work, **when** to create them, and for **which columns**.
|
||||
@@ -171,7 +171,7 @@ The first step is to import the `Session` class:
|
||||
```Python hl_lines="3"
|
||||
{!./docs_src/tutorial/insert/tutorial001.py[ln:1-3]!}
|
||||
|
||||
# Code below ommitted 👇
|
||||
# Code below omitted 👇
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
@@ -81,7 +81,7 @@ In this case, instead of getting all the 7 rows, we are limiting them to only ge
|
||||
|
||||
<img class="shadow" alt="table with first 3 rows selected" src="/img/tutorial/offset-and-limit/limit.svg">
|
||||
|
||||
## Run the Program on the Comamnd Line
|
||||
## Run the Program on the Command Line
|
||||
|
||||
If we run it on the command line, it will output:
|
||||
|
||||
@@ -93,7 +93,7 @@ $ python app.py
|
||||
// Previous output omitted 🙈
|
||||
|
||||
// Select with LIMIT
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
LIMIT ? OFFSET ?
|
||||
INFO Engine [no key 0.00014s] (3, 0)
|
||||
@@ -153,7 +153,7 @@ Each of those methods applies the change in the internal special select statemen
|
||||
|
||||
**Offset** means "skip this many rows", and as we want to skip the ones we already saw, the first three, we use `.offset(3)`.
|
||||
|
||||
## Run the Program with Offset on the Comamnd Line
|
||||
## Run the Program with Offset on the Command Line
|
||||
|
||||
Now we can run the program on the command line, and it will output:
|
||||
|
||||
@@ -165,7 +165,7 @@ $python app.py
|
||||
// Previous output omitted 🙈
|
||||
|
||||
// Select with LIMIT and OFFSET
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
LIMIT ? OFFSET ?
|
||||
INFO Engine [no key 0.00020s] (3, 3)
|
||||
@@ -207,9 +207,9 @@ The database right now has **only 7 rows**, so this query can only get 1 row.
|
||||
|
||||
But don't worry, the database won't throw an error trying to get 3 rows when there's only one (as would happen with a Python list).
|
||||
|
||||
The database knows that we want to **limit** the number of results, but it doesn't necessarily has to find those many results.
|
||||
The database knows that we want to **limit** the number of results, but it doesn't necessarily have to find that many results.
|
||||
|
||||
## Run the Program with the Last Batch on the Comamnd Line
|
||||
## Run the Program with the Last Batch on the Command Line
|
||||
|
||||
And if we run it in the command line, it will output:
|
||||
|
||||
@@ -221,7 +221,7 @@ $ python app.py
|
||||
// Previous output omitted 🙈
|
||||
|
||||
// Select last batch with LIMIT and OFFSET
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
LIMIT ? OFFSET ?
|
||||
INFO Engine [no key 0.00038s] (3, 6)
|
||||
@@ -241,7 +241,7 @@ You probably noticed the new SQL keywords `LIMIT` and `OFFSET`.
|
||||
You can use them in SQL, at the end of the other parts:
|
||||
|
||||
```SQL
|
||||
SELECT id, name, secret_name, age
|
||||
SELECT id, name, secret_name, age
|
||||
FROM hero
|
||||
LIMIT 3 OFFSET 6
|
||||
```
|
||||
@@ -271,11 +271,11 @@ Of course, you can also combine `.limit()` and `.offset()` with `.where()` and o
|
||||
|
||||
</details>
|
||||
|
||||
## Run the Program with Limit and Where on the Comamnd Line
|
||||
## Run the Program with Limit, Offset, and Where on the Command Line
|
||||
|
||||
If we run it on the command line, it will find all the heroes in the database with an age above 32. That would normally be 4 heroes.
|
||||
|
||||
But we are limiting the results to only get the first 3:
|
||||
But we are starting to include after an offset of 1 (so we don't count the first one), and we are limiting the results to only get the first 2 after that:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
@@ -284,18 +284,17 @@ $ python app.py
|
||||
|
||||
// Previous output omitted 🙈
|
||||
|
||||
// Select with WHERE and LIMIT
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
// Select with WHERE and LIMIT and OFFSET
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.age > ?
|
||||
LIMIT ? OFFSET ?
|
||||
INFO Engine [no key 0.00022s] (32, 3, 0)
|
||||
INFO Engine [no key 0.00022s] (32, 2, 1)
|
||||
|
||||
// Print the heroes received, only 3
|
||||
// Print the heroes received, only 2
|
||||
[
|
||||
Hero(age=35, secret_name='Trevor Challa', id=5, name='Black Lion'),
|
||||
Hero(age=36, secret_name='Steve Weird', id=6, name='Dr. Weird'),
|
||||
Hero(age=48, secret_name='Tommy Sharp', id=3, name='Rusty-Man')
|
||||
Hero(age=36, id=6, name='Dr. Weird', secret_name='Steve Weird'),
|
||||
Hero(age=48, id=3, name='Rusty-Man', secret_name='Tommy Sharp')
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
@@ -122,16 +122,16 @@ INFO Engine COMMIT
|
||||
// Automatically start a new transaction
|
||||
INFO Engine BEGIN (implicit)
|
||||
// Refresh the data
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [generated in 0.00019s] (1,)
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.001959s ago] (2,)
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
INFO Engine SELECT hero.id, hero.name, hero.secret_name, hero.age
|
||||
FROM hero
|
||||
WHERE hero.id = ?
|
||||
INFO Engine [cached since 0.003215s ago] (3,)
|
||||
|
||||
@@ -139,8 +139,8 @@ INFO Engine [cached since 0.003215s ago] (3,)
|
||||
Deadpond: name='Deadpond' age=None id=1 secret_name='Dive Wilson'
|
||||
|
||||
// Accessing the .team attribute triggers a refresh
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
WHERE ? = heroteamlink.hero_id AND team.id = heroteamlink.team_id
|
||||
INFO Engine [generated in 0.00025s] (1,)
|
||||
|
||||
@@ -151,8 +151,8 @@ Deadpond teams: [Team(id=1, name='Z-Force', headquarters='Sister Margaret’s Ba
|
||||
Rusty-Man: name='Rusty-Man' age=48 id=2 secret_name='Tommy Sharp'
|
||||
|
||||
// Accessing the .team attribute triggers a refresh
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
WHERE ? = heroteamlink.hero_id AND team.id = heroteamlink.team_id
|
||||
INFO Engine [cached since 0.001716s ago] (2,)
|
||||
|
||||
@@ -163,8 +163,8 @@ Rusty-Man Teams: [Team(id=2, name='Preventers', headquarters='Sharp Tower')]
|
||||
Spider-Boy: name='Spider-Boy' age=None id=3 secret_name='Pedro Parqueador'
|
||||
|
||||
// Accessing the .team attribute triggers a refresh
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
INFO Engine SELECT team.id AS team_id, team.name AS team_name, team.headquarters AS team_headquarters
|
||||
FROM team, heroteamlink
|
||||
WHERE ? = heroteamlink.hero_id AND team.id = heroteamlink.team_id
|
||||
INFO Engine [cached since 0.002739s ago] (3,)
|
||||
|
||||
@@ -179,4 +179,4 @@ INFO Engine ROLLBACK
|
||||
|
||||
## Recap
|
||||
|
||||
After setting up the model link, using it with **relationship attributes** is fairly straighforward, just Python objects. ✨
|
||||
After setting up the model link, using it with **relationship attributes** is fairly straightforward, just Python objects. ✨
|
||||
|
||||
@@ -40,7 +40,7 @@ And **both fields are primary keys**. We hadn't used this before. 🤓
|
||||
Let's see the `Team` model, it's almost identical as before, but with a little change:
|
||||
|
||||
```Python hl_lines="8"
|
||||
# Code above ommited 👆
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/many_to_many/tutorial001.py[ln:15-20]!}
|
||||
|
||||
@@ -56,7 +56,7 @@ Let's see the `Team` model, it's almost identical as before, but with a little c
|
||||
|
||||
</details>
|
||||
|
||||
The **relationship attribute `heroes`** is still a list of heroes, annotatted as `List["Hero"]`. Again, we use `"Hero"` in quotes because we haven't declared that class yet by this point in the code (but as you know, editors and **SQLModel** understand that).
|
||||
The **relationship attribute `heroes`** is still a list of heroes, annotated as `List["Hero"]`. Again, we use `"Hero"` in quotes because we haven't declared that class yet by this point in the code (but as you know, editors and **SQLModel** understand that).
|
||||
|
||||
We use the same **`Relationship()`** function.
|
||||
|
||||
@@ -69,7 +69,7 @@ And here's the important part to allow the **many-to-many** relationship, we use
|
||||
Let's see the other side, here's the `Hero` model:
|
||||
|
||||
```Python hl_lines="9"
|
||||
# Code above ommited 👆
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/many_to_many/tutorial001.py[ln:23-29]!}
|
||||
|
||||
@@ -102,7 +102,7 @@ And now we have a **`link_model=HeroTeamLink`**. ✨
|
||||
The same as before, we will have the rest of the code to create the **engine**, and a function to create all the tables `create_db_and_tables()`.
|
||||
|
||||
```Python hl_lines="9"
|
||||
# Code above ommited 👆
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/many_to_many/tutorial001.py[ln:32-39]!}
|
||||
|
||||
@@ -122,7 +122,7 @@ The same as before, we will have the rest of the code to create the **engine**,
|
||||
And as in previous examples, we will add that function to a function `main()`, and we will call that `main()` function in the main block:
|
||||
|
||||
```Python hl_lines="4"
|
||||
# Code above ommited 👆
|
||||
# Code above omitted 👆
|
||||
|
||||
{!./docs_src/tutorial/many_to_many/tutorial001.py[ln:78-79]!}
|
||||
# We will do more stuff here later 👈
|
||||
@@ -149,37 +149,37 @@ If you run the code in the command line, it would output:
|
||||
```console
|
||||
$ python app.py
|
||||
|
||||
// Boilerplate ommited 😉
|
||||
// Boilerplate omitted 😉
|
||||
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
CREATE TABLE team (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
headquarters VARCHAR NOT NULL,
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
headquarters VARCHAR NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
|
||||
INFO Engine [no key 0.00033s] ()
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
CREATE TABLE hero (
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
id INTEGER,
|
||||
name VARCHAR NOT NULL,
|
||||
secret_name VARCHAR NOT NULL,
|
||||
age INTEGER,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
|
||||
INFO Engine [no key 0.00016s] ()
|
||||
INFO Engine
|
||||
INFO Engine
|
||||
|
||||
// Our shinny new link table ✨
|
||||
CREATE TABLE heroteamlink (
|
||||
team_id INTEGER,
|
||||
hero_id INTEGER,
|
||||
PRIMARY KEY (team_id, hero_id),
|
||||
FOREIGN KEY(team_id) REFERENCES team (id),
|
||||
team_id INTEGER,
|
||||
hero_id INTEGER,
|
||||
PRIMARY KEY (team_id, hero_id),
|
||||
FOREIGN KEY(team_id) REFERENCES team (id),
|
||||
FOREIGN KEY(hero_id) REFERENCES hero (id)
|
||||
)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ Notice that each hero can only have **one** connection. But each team can receiv
|
||||
|
||||
## Introduce Many-to-Many
|
||||
|
||||
But let's say that as **Deadpond** is a great chracter, they recruit him to the new **Preventers** team, but he's still part of the **Z-Force** team too.
|
||||
But let's say that as **Deadpond** is a great character, they recruit him to the new **Preventers** team, but he's still part of the **Z-Force** team too.
|
||||
|
||||
So, now, we need to be able to have a hero that is connected to **many** teams. And then, each team, should still be able to receive **many** heroes. So we need a **Many-to-Many** relationship.
|
||||
|
||||
|
||||