Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ARRAY_AGG two columns into one item in SQLAlchemy?

Can anybody suggest how to convert this code into SQLAlchemy code?

ARRAY_AGG(DISTINCT (table.column_a, table.column_b)) AS label
like image 680
Alex Isayko Avatar asked Oct 15 '25 12:10

Alex Isayko


1 Answers

Found the solution

from sqlalchemy import func
func.array_agg(func.distinct(table.column_a, table.column_b)).label('my_label')
like image 107
Alex Isayko Avatar answered Oct 17 '25 00:10

Alex Isayko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!