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
I used the GitHub search to find a similar question 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.
Commit to Help
I commit to help with one of those options 👆
Example Code
toto
Description
I'm starting with the ORM and I try y best to right as few things as possible and hand over complex things to the lib.
I would like to create the following class:
classCropMask(Base, table=True):
"""Cropmask used to filter data when loading indicators from GEE. All the cropmasks are exported as images in GEE to accelerate computation. """id: Optional[int] =Field(default=None, primary_key=True)
name: str"technical name of the asset. Use snake case like 'esa_crop'"asset_id: str"the binary asset to use as a mask image"geolocations: list["Geolocation"] =Relationship(back_populates="crop_mask")
"The geolocations that use this cropmask"
and add a relation with the geolocation class as :
classGeolocation(Base, table=True):
"""The geolocation as defined in MDM. The Geolocation are aggregation of multiple administrative areas from GADM. They are used to reduce the amount of reducers to compute when downloading an indicator from GEE. For example we don't need to download all France département when computing Wheat related indicators, only the ones where Wheat is grown. The values of this table should be populated from MDM sources at building stage of the DB to match company description of geometries. """id: Optional[int] =Field(default=None, primary_key=True)
gid_ldc: str"The name of the geolocation"display_name: str"The name use by platform member to name this aggregation"crop_mask_id: Optional[int] =Field(default=None, foreign_key="crop_mask.id")
crop_mask: Optional[CropMask] =Relationship(back_populates="geolocations")
"The cropmask used to filter the data when computing indicators"
In the Field definition, I need to use the table name and if I'm correct this name is generated from the class name by default. The default behaviour seems to be CropMask -> cropmask but I would prefer to have snake case names. AS I would this behaviour to be available to all my classe, is there a way to modify how the SQLModel generate table names when the tablename is missing ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First Check
Commit to Help
Example Code
toto
Description
I'm starting with the ORM and I try y best to right as few things as possible and hand over complex things to the lib.
I would like to create the following class:
and add a relation with the geolocation class as :
In the
Field
definition, I need to use the table name and if I'm correct this name is generated from the class name by default. The default behaviour seems to beCropMask
->cropmask
but I would prefer to have snake case names. AS I would this behaviour to be available to all my classe, is there a way to modify how theSQLModel
generate table names when the tablename is missing ?Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.19
Python Version
3.10
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions