- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 742
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
First Check
- I added a very descriptive title to this issue.I used the GitHub search to find a similar issue and didn't find it.I searched the SQLModel documentation, with the integrated search.I already searched in Google "How to X in SQLModel" and didn't find any information.I already read and followed all the tutorial in the docs and didn't find an answer.I already checked if it is not related to SQLModel but to Pydantic.I already checked if it is not related to SQLModel but to SQLAlchemy.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Commit to Help
- I commit to help with one of those options 👆To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Example Code
from sqlmodel import Field, Relationship, SQLModel
class Measure(SQLModel, table=True):
t: int = Field(primary_key=True, description='Unix epoch when the measure was performed')
Description
I want to add comments on columns and tables that can be seen also in the generated SQL DB
No 'comment' parameter could be found in the 'Field' function. I found the 'description' parameter but it has no effect on the generated schema and I couldn't find any information on what's the use of this attribute.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.8
Python Version
3.7.3
Additional Context
No response
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
meirdev commentedon Nov 9, 2022
If your database allows
comment on column
you can use comment parameter:tiangolo commentedon Nov 9, 2022
Thanks for the help @meirdev ! 🤓☕
AlekseyFedorovich commentedon Nov 9, 2022
it works, in analogy with SQLAlchemy I found a way to comment tables too:
Still I don't understand what's the use of
description
parameter in functionField
tiangolo commentedon Nov 10, 2022
Thanks for coming back to close it! ☕
AlekseyFedorovich commentedon Nov 10, 2022
You are welcome.
Anyway, I tested the application because it looked so promising but unfortunately I don't think I will continue using it.
The docs are to way too poor and also exploring the code there is no comment at all.
Also pydantic validation doesn't seem to work, as far as I understood for precedent issues: again no docs about that so is difficult to tell.
I'm sorry.
aptly-io commentedon Jul 6, 2023
(Interesting to learn about the
comment
feature for documenting the database)I'm surprised to read about the poor documentation. I'm using FastAPI and SQLModel recently and feel these come with extensive (and easy accessible) documentation/tutorials pages (I'd even say too much :-))
PaleNeutron commentedon Mar 27, 2024
Maybe it's time for us to consider this feature again. pydantic can use Python docstring as field description soon! pydantic/pydantic#6563
Currently, when user create a sqlmodel, they usually create description at 3 place.
In the pass, we cureate a custom field object to make
description
andsa_column_kwargs.comment
one:But consider the pull request mentioned above, pydantic can use docstring as description now, but the custom field can not get it since it is done during class creation.
Can sqlmodel follow pydantic's change and provide some configuration to merge the three type of descriptions to one? @tiangolo
PaleNeutron commentedon Mar 27, 2024
I create a new basemodel, use if instead of
SQLModel
will automatically setcomment
to Column.For anyone who want this feature
KunxiSun commentedon May 22, 2024
@PaleNeutron I think I will probably like the style to override the Field function,👇🏻(not tested pseudocode)
iloveitaly commentedon Jun 7, 2024
Has anyone figured out how to add the model docstr as a comment on the SQL table?
olisom commentedon Aug 7, 2024
3 remaining items