A. Comparison between native SQL statements and asq statements
Suppose there is an SQL query statement:
Select ID, IP, CH, date from TBL group by CH, date;
To use the group_by method of the asq module of Python, You can implement the following: (1) Obtain res_list through SQL query of all records; (2) then use the asq function:
Query (res_list). group_by (lambda P: P [2], Lambda P: P [3]). Select (lambda mem: Mem [0]). to_list ();
In fact, the main logic is to obtain all data through SQL, and then asq first groups, then selects the first record of each group, and finally returns the result list.
B. AdvantagesIn addition, if there is only one query statement, there is no need to use the asq module function, because the performance cannot be better than that of native SQL queries. Compared with native SQL queries, asq has the primary advantage of minimizing the number of table scans in some cases.