Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to select specific fields? #102

Open
albertalexandrov opened this issue May 6, 2023 · 1 comment
Open

How to select specific fields? #102

albertalexandrov opened this issue May 6, 2023 · 1 comment

Comments

@albertalexandrov
Copy link

Hi and thanks for the lib!

Could you say please how to select specific fields?

class BusinessUnit(BaseModel):
    __tablename__ = 'businessunit'

    id = Column(Integer, autoincrement=True, unique=True, primary_key=True, nullable=False)
    code = Column(Text, nullable=False, unique=True)
    name = Column(Text, nullable=False)

Now I'm forced to do like this:

BusinessUnit._session.query(BusinessUnit.code, BusinessUnit.id).all()

@michaelbukachi
Copy link
Collaborator

@albertalexandrov What would be the result for this scenario? 1. A Result (tuple) object, a full object with only the select fields loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants