예제 #1
0
    def explain(self, quals, columns, sortkeys=None, verbose=False):
        query = quals_to_socrata(quals, self.column_map)
        select = cols_to_socrata(columns, self.column_map)
        order = sortkeys_to_socrata(sortkeys, self.column_map)

        return [
            "Socrata query to %s" % self.domain,
            "Socrata dataset ID: %s" % self.table,
            "Query: %s" % query,
            "Columns: %s" % select,
            "Order: %s" % order,
        ]
예제 #2
0
    def execute(self, quals, columns, sortkeys=None):
        """Main Multicorn entry point."""
        query = quals_to_socrata(quals, self.column_map)
        select = cols_to_socrata(columns, self.column_map)
        order = sortkeys_to_socrata(sortkeys, self.column_map)

        logging.debug("Socrata query: %r, select: %r, order: %r", query,
                      select, order)

        # TODO offsets stop working after some point?
        result = self.client.get_all(
            dataset_identifier=self.table,
            where=query,
            select=select,
            limit=self.batch_size,
            order=order,
        )

        for r in result:
            r = to_json(r, columns, self.column_map)
            yield r
예제 #3
0
def test_socrata_quals(quals, expected):
    assert quals_to_socrata(quals) == expected