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'm able to export records as a csv from the sqladmin backend. Sqladmin only allows limited configuration of the export format and I end up with the following export data for my many-to-many relationship called "assessed_in":
# Database Models
class PeriodStatusEnum(str, enum.Enum):
in_assessment = "in_assessment"
readonly = "readonly"
hidden = "hidden"
class Period(BaseClass, table=True):
period_id: str = Field(index=True, unique=True)
name: str
status: PeriodStatusEnum = Field(sa_column=Column(Enum(PeriodStatusEnum)))
class DimensionPeriodLink(SQLModel, table=True):
dimension_id: int | None = Field(default=None, foreign_key="dimension.id", primary_key=True)
period_id: int | None = Field(default=None, foreign_key="period.id", primary_key=True)
class Dimension(BaseClass, table=True):
dimension_id: str = Field(index=True, unique=True)
name_EN: str
name_DE: str
order_nr: int
assessed_in: list[Period] = Relationship(link_model=DimensionPeriodLink)
In a later stage I need to read in the csv and create the records with the many to many relationship in python -> which works fine for all attributes except the "assessed_in" m2m relationship (as it's not a pure dict).
What would be a smart solution to parse that model including the relationship with pydantic/sqlmodel?
Thanks a lot for your inputs, it's highly appreciated! <3
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
-
Hi
I'm able to export records as a csv from the sqladmin backend. Sqladmin only allows limited configuration of the export format and I end up with the following export data for my many-to-many relationship called "assessed_in":
My models are setup as follows:
In a later stage I need to read in the csv and create the records with the many to many relationship in python -> which works fine for all attributes except the "assessed_in" m2m relationship (as it's not a pure dict).
What would be a smart solution to parse that model including the relationship with pydantic/sqlmodel?
Thanks a lot for your inputs, it's highly appreciated! <3
Beta Was this translation helpful? Give feedback.
All reactions