Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SQLAlchemy have bool_and aggregate function?

I want to use bool_and aggregate function for GROUP BY, but I do not understand how to implement it in SQLAlchemy. I have tried func.and_ but it does not seem to work.

like image 988
Shiva Rama Pranav Avatar asked Oct 17 '25 16:10

Shiva Rama Pranav


1 Answers

You can create (almost) any SQL function expression from func by its name:

Note that any name not known to func generates the function name as is - there is no restriction on what SQL functions can be called, known or unknown to SQLAlchemy, built-in or user defined.

So the answer is just:

func.bool_and(...)

There are some functions that are known to SQLAlchemy and get special treatment, such as CURRENT_TIMESTAMP.

like image 163
Ilja Everilä Avatar answered Oct 20 '25 08:10

Ilja Everilä