-
-
Notifications
You must be signed in to change notification settings - Fork 769
📝 Add tutorial and advanced page for EncryptedType
#1574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit beb184f at: https://22b95713.sqlmodel.pages.dev Modified Pages |
I am seeing in the sqlalchemy-utils docs that EncryptionType is deprecating in favor |
EncryptedType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ravishan16, thank you for your interest and efforts!
The example is interesting, but I think this should be a section of docs about sa_column
property (the code example boils down to just using sa_column
to specify SQLAlchemy type for the field).
I also don't think we should add 2 sections about this. I think it should be in Advanced section only.
What do you think?
📝 Docs previewLast commit 692ae8f at: https://f5aeaf54.sqlmodel.pages.dev Modified Pages |
…ueness tutorials; remove deprecated encrypted-type page; update nav and run notes
f4ae1b4
to
00b594f
Compare
…t with sa_column; tidy examples and messages
Thanks @YuriiMotov for the thoughtful feedback, completely agree. I’ve reworked this into a single Advanced page focused on sa_column. The encryption piece is now just one example of passing a fully configured SQLAlchemy Column, rather than a standalone “encrypted type” doc. Summary of changes: If you’d prefer to keep just one example (e.g., only the encrypted field) or adjust the tone/titles, I’m happy to trim or tweak as needed or you can change it as needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ravishan16, thank you!
It's already very helpful! But I think we should try to make the style more consistent with other sections. Please, take a look at my comments below.
As for enforcing uniqueness
use case - I don't see any advantage of using Column
here. I would remove this part to not overload docs with. We can later add more use-cases.
Also, I think we should create a sub-group inside Advanced
section like Advanced Column Configuration
(let's think about the name, this is just a suggestion) where we will place all things related to customization with sa_column
, sa_column_args
, sa_type
, sa_column_kwargs
.
|
||
Note: `StringEncryptedType` provides explicit string type handling and better compatibility with SQLAlchemy 2.x. | ||
|
||
{* ./docs_src/advanced/sa_column/tutorial001.py *} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to explain this in a bit more details, make it a bit more entertaining and step-by-step.
Something like (very raw draft):
Remember we have
secret_name
fields for every Hero?
What if the DB leakage happens and all data becomes public? Everyone will know secret names of our heroes.. 😱
Let's try to mitigate such security risks by introducing data encryption for sensitive data.
All we need is to useStringEncryptedType
DB type forsecret_name
An then add a part of code example (only related lines with most important lines highlighted) like this
{* ./docs_src/advanced/sa_column/tutorial001.py ln[1:28] hl[4:8,11:12,20:26] *}
Then describe in short what is happening in select_heroes
.
```bash | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
pip install sqlmodel sqlalchemy-utils cryptography |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use standardized text for installation part (see how it's done for fastapi-related section) and move it to the beginning (inside ## Use case: encrypted field with a custom type
)
## Use case: encrypted field with a custom type
### Install `sqlalchemy-utils` and `cryptography` packeges
The first step is to install `sqlalchemy-utils` and `cryptography` packeges.
Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install them, for example with:
<div class="termy">
```console
$ pip install sqlmodel sqlalchemy-utils cryptography
---> 100%
```
</div>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Closes #447
This pull request adds documentation for using EncryptedType with SQLModel. It includes: