You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/decimal.md
+22-10Lines changed: 22 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,15 +21,21 @@ In most cases this would probably not be a problem, for example measuring views
21
21
22
22
Pydantic has special support for `Decimal` types using the <ahref="https://pydantic-docs.helpmanual.io/usage/types/#arguments-to-condecimal"class="external-link"target="_blank">`condecimal()` special function</a>.
23
23
24
-
!!! tip
25
-
Pydantic 1.9, that will be released soon, has improved support for `Decimal` types, without needing to use the `condecimal()` function.
24
+
/// tip
26
25
27
-
But meanwhile, you can already use this feature with `condecimal()` in **SQLModel** it as it's explained here.
26
+
Pydantic 1.9, that will be released soon, has improved support for `Decimal` types, without needing to use the `condecimal()` function.
27
+
28
+
But meanwhile, you can already use this feature with `condecimal()` in **SQLModel** it as it's explained here.
29
+
30
+
///
28
31
29
32
When you use `condecimal()` you can specify the number of digits and decimal places to support. They will be validated by Pydantic (for example when using FastAPI) and the same information will also be used for the database columns.
30
33
31
-
!!! info
32
-
For the database, **SQLModel** will use <ahref="https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.DECIMAL"class="external-link"target="_blank">SQLAlchemy's `DECIMAL` type</a>.
34
+
/// info
35
+
36
+
For the database, **SQLModel** will use <ahref="https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.DECIMAL"class="external-link"target="_blank">SQLAlchemy's `DECIMAL` type</a>.
37
+
38
+
///
33
39
34
40
## Decimals in SQLModel
35
41
@@ -72,8 +78,11 @@ We are also saying that the number of decimal places (to the right of the decima
72
78
*`123`
73
79
* Even though this number doesn't have any decimals, we still have 3 places saved for them, which means that we can **only use 2 places** for the **integer part**, and this number has 3 integer digits. So, the allowed number of integer digits is `max_digits` - `decimal_places` = 2.
74
80
75
-
!!! tip
76
-
Make sure you adjust the number of digits and decimal places for your own needs, in your own application. 🤓
81
+
/// tip
82
+
83
+
Make sure you adjust the number of digits and decimal places for your own needs, in your own application. 🤓
84
+
85
+
///
77
86
78
87
## Create models with Decimals
79
88
@@ -142,7 +151,10 @@ Total money: 3.300
142
151
143
152
</div>
144
153
145
-
!!! warning
146
-
Although Decimal types are supported and used in the Python side, not all databases support it. In particular, SQLite doesn't support decimals, so it will convert them to the same floating `NUMERIC` type it supports.
154
+
/// warning
155
+
156
+
Although Decimal types are supported and used in the Python side, not all databases support it. In particular, SQLite doesn't support decimals, so it will convert them to the same floating `NUMERIC` type it supports.
157
+
158
+
But decimals are supported by most of the other SQL databases. 🎉
147
159
148
-
But decimals are supported by most of the other SQL databases. 🎉
Copy file name to clipboardExpand all lines: docs/databases.md
+21-9Lines changed: 21 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,12 @@
1
1
# Intro to Databases
2
2
3
-
!!! info
4
-
Are you a seasoned developer and already know everything about databases? 🤓
3
+
/// info
5
4
6
-
Then you can skip to the [Tutorial - User Guide: First Steps](tutorial/index.md){.internal-link target=_blank} right away.
5
+
Are you a seasoned developer and already know everything about databases? 🤓
6
+
7
+
Then you can skip to the [Tutorial - User Guide: First Steps](tutorial/index.md){.internal-link target=_blank} right away.
8
+
9
+
///
7
10
8
11
If you don't know everything about databases, here's a quick overview.
9
12
@@ -17,8 +20,11 @@ So, what is a database?
17
20
18
21
A **database** is a system to store and manage data in a structured and very efficient way.
19
22
20
-
!!! tip
21
-
It's very common to abbreviate the word "database" as **"DB"**.
23
+
/// tip
24
+
25
+
It's very common to abbreviate the word "database" as **"DB"**.
26
+
27
+
///
22
28
23
29
As there's a lot of information about databases, and it can get very technical and academic, I'll give you a quick overview about some of the main concepts here.
24
30
@@ -28,8 +34,11 @@ I'll even tell you a bit about different types of databases, including the ones
28
34
29
35
When starting to program, it might **not be obvious** why having a database apart from the code for your program is a **good idea**. Let's start with that.
30
36
31
-
!!! tip
32
-
If that's obvious to you, just continue in the next section below. 👇
37
+
/// tip
38
+
39
+
If that's obvious to you, just continue in the next section below. 👇
40
+
41
+
///
33
42
34
43
In your code you already have **variables**, **dictionaries**, **lists**, etc. They all store **data** in some way already. Why would you need to have a separate database?
35
44
@@ -308,8 +317,11 @@ Next, it receives the data and puts it in Python objects that you can continue t
308
317
309
318
I'll tell you more about SQL, SQLModel, how to use them, and how they are related in the next sections.
310
319
311
-
!!! info "Technical Details"
312
-
SQLModel is built on top of SQLAlchemy. It is, in fact, just <ahref="https://www.sqlalchemy.org/"class="external-link"target="_blank">SQLAlchemy</a> and <ahref="https://pydantic-docs.helpmanual.io/"class="external-link"target="_blank">Pydantic</a> mixed together with some sugar on top.
320
+
/// info | Technical Details
321
+
322
+
SQLModel is built on top of SQLAlchemy. It is, in fact, just <ahref="https://www.sqlalchemy.org/"class="external-link"target="_blank">SQLAlchemy</a> and <ahref="https://pydantic-docs.helpmanual.io/"class="external-link"target="_blank">Pydantic</a> mixed together with some sugar on top.
Copy file name to clipboardExpand all lines: docs/db-to-code.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,8 +172,11 @@ The difference in the final SQL statement is subtle, but it changes the meaning
172
172
SELECT*FROM hero WHERE id ="2; DROP TABLE hero;";
173
173
```
174
174
175
-
!!! tip
176
-
Notice the double quotes (`"`) making it a string instead of more raw SQL.
175
+
/// tip
176
+
177
+
Notice the double quotes (`"`) making it a string instead of more raw SQL.
178
+
179
+
///
177
180
178
181
The database will not find any record with that ID:
179
182
@@ -187,8 +190,11 @@ Then your code will continue to execute and calmly tell the user that it couldn'
187
190
188
191
But we never deleted the `hero` table. 🎉
189
192
190
-
!!! info
191
-
Of course, there are also other ways to do SQL data sanitization without using a tool like **SQLModel**, but it's still a nice feature you get by default.
193
+
/// info
194
+
195
+
Of course, there are also other ways to do SQL data sanitization without using a tool like **SQLModel**, but it's still a nice feature you get by default.
196
+
197
+
///
192
198
193
199
### Editor Support
194
200
@@ -291,8 +297,11 @@ There are many ORMs available apart from **SQLModel**, you can read more about s
291
297
292
298
## SQL Table Names
293
299
294
-
!!! info "Technical Background"
295
-
This is a bit of boring background for SQL purists. Feel free to skip this section. 😉
300
+
/// info | Technical Background
301
+
302
+
This is a bit of boring background for SQL purists. Feel free to skip this section. 😉
303
+
304
+
///
296
305
297
306
When working with pure SQL, it's common to name the tables in plural. So, the table would be named `heroes` instead of `hero`, because it could contain multiple rows, each with one hero.
298
307
@@ -304,5 +313,8 @@ You will see **your own code** a lot more than the internal table names, so it's
304
313
305
314
So, to keep things consistent, I'll keep using the same table names that **SQLModel** would have generated.
306
315
307
-
!!! tip
308
-
You can also override the table name. You can read about it in the Advanced User Guide.
316
+
/// tip
317
+
318
+
You can also override the table name. You can read about it in the Advanced User Guide.
Copy file name to clipboardExpand all lines: docs/help.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -157,12 +157,15 @@ And if there's any other style or consistency need, I'll ask directly for that,
157
157
158
158
* Then **comment** saying that you did that, that's how I will know you really checked it.
159
159
160
-
!!! info
161
-
Unfortunately, I can't simply trust PRs that just have several approvals.
160
+
/// info
162
161
163
-
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. 😅
162
+
Unfortunately, I can't simply trust PRs that just have several approvals.
164
163
165
-
So, it's really important that you actually read and run the code, and let me know in the comments that you did. 🤓
164
+
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. 😅
165
+
166
+
So, it's really important that you actually read and run the code, and let me know in the comments that you did. 🤓
167
+
168
+
///
166
169
167
170
* 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.
168
171
@@ -209,10 +212,13 @@ If you can help me with that, **you are helping me maintain SQLModel** and makin
209
212
210
213
Join the 👥 <ahref="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.
211
214
212
-
!!! tip
213
-
For questions, ask them in <ahref="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.
215
+
/// tip
216
+
217
+
For questions, ask them in <ahref="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.
218
+
219
+
Use the chat only for other general conversations.
214
220
215
-
Use the chat only for other general conversations.
Copy file name to clipboardExpand all lines: docs/tutorial/connect/index.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,10 @@ But the main advantage and feature of SQL databases is being able to handle rela
6
6
7
7
Let's see how to use **SQLModel** to manage connected data in the next chapters. 🤝
8
8
9
-
!!! tip
10
-
We will extend this further in the next group of chapters making it even more convenient to work with in Python code, using **relationship attributes**.
9
+
/// tip
11
10
12
-
But you should start in this group of chapters first. 🤓
11
+
We will extend this further in the next group of chapters making it even more convenient to work with in Python code, using **relationship attributes**.
12
+
13
+
But you should start in this group of chapters first. 🤓
0 commit comments