Skip to content

Tag: sqlalchemy

How to union two counts queries in SQLAlchemy?

I have two queries and the only difference between then is that one is counting the success status and the other failure status. Is there a way to get this result in just one query? I’m using SQLALchemy to do the queries. Answer You can use conditions on Count, your query will look like:

Case in Sqlalchemy hybrid_property / expression error

I want to use expressions is ORM queries like this. Profile.query.filter(Profile.complete).all() Where complete is a calculated field Sqlalchemy docs shows the below So i’ve attempted to copy it with the following. But the output sql query is as below – the case isn’t compared agaisnt anythi…

SQLAlchemy group by day in timestamp column

I have an ORM (Model) defined in SQLAlchemy as below: I’m planning to get the sum of all views in each day and tried to group the results based on their end_to. I have used the following query in sqlalchemy: But this query throws this error: I am using the timestamp in my model and I don’t plan to…