First Check
Commit to Help
Example Code
ActualData(BaseModel):
id: int
KnownName: str
NickName: str
Mother: str
Father: str
SocialSecurity: int
Pets: Optional[boolean]
Vegan: Optional[boolean]
Database Schema:
id: int
name: str # KnownName
details: str # f"KnownName={KnownName};NickName={NickName};Mother={Mother};Father={Father};SocialSecurity={SocialSecurity};Pets={Pets};Vegan={Vegan}"
Description
I have a very strange constraint, I am using SQLModel as my orm. I have a database with two important fields, for example name and details. The important information I need for my model ActualData is built from the details column from the database.
How do I use the ActualData model in my code, but when I submit/save/read from the database, it is encoded as a character delimited string structure?
pydantic/validators was very helpful but it fills one field. Is it possible to fill out the entire model with one validator? How does one encode the model back to a single string within the database?
Operating System
Windows
Operating System Details
- win11 pro, python from windows store, pipenv
SQLModel Version
0.0.8
Python Version
3.10.8
Additional Context
Think of storing the string components of postgresql database connection string, but storing it as a completed connection string
User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;
First Check
Commit to Help
Example Code
Description
I have a very strange constraint, I am using SQLModel as my orm. I have a database with two important fields, for example
nameanddetails. The important information I need for my modelActualDatais built from thedetailscolumn from the database.How do I use the
ActualDatamodel in my code, but when I submit/save/read from the database, it is encoded as a character delimited string structure?pydantic/validators was very helpful but it fills one field. Is it possible to fill out the entire model with one validator? How does one encode the model back to a single string within the database?
Operating System
Windows
Operating System Details
SQLModel Version
0.0.8
Python Version
3.10.8
Additional Context
Think of storing the string components of postgresql database connection string, but storing it as a completed connection string
User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;