I'm using the PostgreSQL and Python database to query it, I have the following modeling:
I'mtryingtomakeaquerythatreturnsallOrderItems
ofaOrder
toaarray
,forthisImadethefollowingcode:
selectARRAY(SELECT'('||translate(string_to_array(x.*::"text", ',')::text, '{()}', '') || ')'
from "OrderItem" x
)::"OrderItem"[] AS "_AAA";
What returns me the following result:
"{"(16,1,ProductName1,M,45.00,1,6)","(17,6,ProductName2,M,45.00,1,6)"}"
In Python I'm using psycopg2
to talk to the database, and so it returns me a string, just like in the above result, not being able to iterate through it to get the tuples with the values.
Does anyone have any idea how I can do this query to return an array of OrderItem?