-
-
Notifications
You must be signed in to change notification settings - Fork 692
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 columns from database table? #232
Comments
Perhaps there are other / better ways, but examining the echoed SQL, this seems to work:
Or (addressing your 2nd question) via: |
Thanks, the However, I am facing some problems when I want to implement this approach in my |
If you make the fields of your
|
For reference, it is possible to select columns like this: with Session(engine) as session:
heroes = session.exec(
select(
Hero.id,
Hero.name
)
).all() However, the return type is |
Thanks both |
Thanks for the help here @byrman and @StefanBrand ! 👏 🙇 Thanks for reporting back and closing the issue @christianholland 👍 |
Is this still the best way to select only specific columns? |
It seems to (still) be working great.
|
First Check
Commit to Help
Example Code
Description
In the docu it is mentioned that it is possible to select only specific columns from the datatable. However, the example is only given for
SQL
and not forSQLModel
So how can I implement this query in SQLModel?
Finally I also dont want to hardcode the column of interest but the column name(s) will be stored in a variable.
Operating System
Windows
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
3.8.1
Additional Context
No response
The text was updated successfully, but these errors were encountered: