Package pylal :: Module ligolw_sqlutils :: Class aggregate_concatenate
[hide private]
[frames] | no frames]

Class aggregate_concatenate

source code

This class builds on the concatenate method to allow string concatenation
across multiple columns and rows. These strings can then be compared in
SQLite. For example, if one wanted to match ids from two different tables that share
the same values, one would do:

from pylal import ligolw_sqlutils as sqlutils
connection.create_aggregate("agg_concatenate", 2, sqlutils.aggregate_concatenate)
    FROM a, b
            SELECT agg_concatenate(a.val1, a.val2) 
            FROM a 
            GROUP BY id
            ORDER BY a.val1, a.val2 ASC
       ) == (
            SELECT agg_concatenate(b.val1, b.val2) 
            FROM b 
            GROUP BY id
            ORDER BY b.val1, b.val2 ASC

In the strings that are created, rows are seperated by ",", columns by ":".

Note that the create_aggregate method must be called first with the number of 
values that will be passed to aggregate_concatenate before using it in any query.

Instance Methods [hide private]
__init__(self) source code
step(self, *args) source code
finalize(self) source code