fastapi / sqlmodel

SQL databases in Python, designed for simplicity, compatibility, and robustness.
https://sqlmodel.tiangolo.com/
MIT License
14.34k stars 635 forks source link

Add support for deferred column loading #97

Open hitman-gdg opened 3 years ago

hitman-gdg commented 3 years ago

First Check

Commit to Help

Example Code

from sqlmodel import deferred

class User(sqlmodel, table=True):
    id: Optional[int] = Field(primary_key=True, default=None)
    name: str
    data: Optional[bytes] = Field(deferred=True)

Description

The ability to be able to included deferred sql columns

Wanted Solution

I would like to be able to work with sqlalchemy deferred columns, so that certain columns are not loaded by default as part of a model

Wanted Code

from sqlmodel import deferred

Alternatives

No response

Operating System

macOS

Operating System Details

No response

SQLModel Version

0.0.4

Python Version

3.9.6

Additional Context

No response

eddcorts commented 2 years ago

Having same issue, did you find any alternative with base SQLAlchemy or something?

FilipeMarch commented 1 year ago

Did you find a solution?

lucas-labs commented 11 months ago

I think that we can use the new sa_type now, in order to achieve this behaviour.

ngi commented 6 months ago

any news how to use sa_type for deferred loading?