How to use a SQL View with Pony ORM

Viewed 2172

I'm trying to fetch the data returned by a View in MySQL using Pony ORM but the documentation does not provide any information on how to achieve this (well, I couldn't find any solution until this moment). Can Pony ORM do this? If so, what should I do to get it working?

Here is my MySQL View:

CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `admin`@`%` 
SQL SECURITY DEFINER
VIEW `ResidueCountByDate` AS
SELECT 
    CAST(`ph`.`DATE` AS DATE) AS `Date`,
    COUNT(`art`.`RESIDUE_TYPE_ID`) AS `Aluminum Count`,
    COUNT(`prt`.`RESIDUE_TYPE_ID`) AS `PET Count`
FROM
    ((((`TBL_PROCESS_HISTORY` `ph`
    JOIN `TBL_RESIDUE` `pr` ON ((`ph`.`RESIDUE_ID` = `pr`.`RESIDUE_ID`)))
    LEFT JOIN `TBL_RESIDUE_TYPE` `prt` ON (((`pr`.`RESIDUE_TYPE_ID` = `prt`.`RESIDUE_TYPE_ID`)
        AND (`prt`.`DESCRIPTION` = 'PET'))))
    JOIN `TBL_RESIDUE` `ar` ON ((`ph`.`RESIDUE_ID` = `ar`.`RESIDUE_ID`)))
    LEFT JOIN `TBL_RESIDUE_TYPE` `art` ON (((`ar`.`RESIDUE_TYPE_ID` = `art`.`RESIDUE_TYPE_ID`)
        AND (`art`.`DESCRIPTION` = 'ALUMINUM'))))
GROUP BY CAST(`ph`.`DATE` AS DATE)
ORDER BY CAST(`ph`.`DATE` AS DATE)
1 Answers
Related