First Check
Commit to Help
Example Code
from typing import Optional
from sqlmodel import Field, SQLModel
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
name: str
secret_name: str
hero_1 = Hero(id=7, name="Deadpond", secret_name="Dive Wilson")
Description
Let say I have an instance of a model
I want to upsert hero_1 into the database: insert if this id does not exist yet, otherwise update. Is there a pattern to do that?
Operating System
Linux, macOS
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.6
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Let say I have an instance of a model
I want to upsert
hero_1into the database: insert if this id does not exist yet, otherwise update. Is there a pattern to do that?Operating System
Linux, macOS
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.9.6
Additional Context
No response