Replies: 2 comments 3 replies
-
Hello, same issue here, even with a simpler model like: from sqlmodel import create_engine, SQLModel, Session, Field
class Example(SQLModel, table=True):
file_path: str = Field(default=None, primary_key=True)
person_number: int
person_list: list[str]
engine = create_engine("postgresql://....", echo=True)
SQLModel.metadata.create_all(engine)
to_rec = Example(file_path="asd",
person_number=2,
person_list=['a', 'b'])
with Session(engine) as session:
session.add(to_rec)
session.commit() Running with |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello! Glad I can help.@Ka2e @vlavorini from sqlmodel import (
SQLModel,
Field,
Column,
JSON,
)
class User(SQLModel, table=True):
__tablename__ = "t_user"
id: int = Field(primary_key=True)
num_list: list = Field(default=[], sa_type=JSON) The magic here is to use the field |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
I have some class extends from sqlmodel class with json fields, but it raise error:
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.21
Python Version
3.11
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions