well you can do `select('*')` if you want but if you want the rows interpreted
as Entry objects and not individual column objects you need to tell that to the
program.
select * at the moment works more easily with a core execution, like this:
query = (
select('*').select_from(Entry)
I see, thank you for the assistance.
Doing stuff like this would be a LOT easier if there was an equivalent to
"SELECT *"
On Sunday, July 10, 2022 at 10:54:19 AM UTC-6 Mike Bayer wrote:
> well your final select() is only against Entry, you don't have the daily
> expected calories part in the
well your final select() is only against Entry, you don't have the daily
expected calories part in the list of columns you are expecting. Also, your
Entry class has no attribute called daily_calories_less_than_expected on it
directly.
there's two ways to get the data you want, one is to
I suppose adding the "for" loop may be unnecessary.
Simply change print(entry) in the s.scalars loop to
print(entry.daily_calories_less_than_expected) and you'll (hopefully)
receive a similar error: "AttributeError: 'Entry' object has no attribute
'daily_calories_less_than_expected'"
On
Thank you, Mike, and apologies for not providing a stack trace or MCVE of
my own - I assumed the code I did provide was sufficient.
So, take your program and add
for entry in s.execute(query):
print(entry.daily_calories_less_than_expected)
to the bottom. This represents what I'm trying to
I've converted your fragments into a full MCVE and it runs fine, no error is
generated. would need to see a stack trace. Try out the program below also.
import datetime
from sqlalchemy import Column
from sqlalchemy import create_engine
from sqlalchemy import Date
from sqlalchemy import
Hi folks!
I have a rather complicated SQL query to perform. I kind of know how I
would do it in SQL and am looking to port it to SQLAlchemy.
I have these ORM classes:
class User(Base):
__tablename__ = "Users"
id = Column(Integer, primary_key=True)
username = Column(String)