Skip to content
Discussion options

You must be logged in to vote

Hi, had the same Question and it seems to work when you declare the column as JSON via Field(sa_column=Column(JSON)...
But there is one caveat; The value read from database is not a named tuple anymore but a list. One could start a conversation if that is a bug or wanted behavior or technical unavoidable behavior.. i dont know
Heres my test code, based on yours, that may help you:

from typing import NamedTuple
import uuid

from pydantic import PositiveInt
from sqlmodel import Field, SQLModel, create_engine, Session, select, Column, JSON

engine = create_engine(url="sqlite:///./testdb.sqlite")

class Coordinates(NamedTuple):
    latitude: float
    longitude: float
    altitude: float

class 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants