@call
    def query(self, q, *args, **kw):
        rows = kw.pop('buffer', 0)
        assert not kw, ("unknown keyword arguments: %r" % kw)

        prepared = self._queue_query(q, args)

        self._execute(rows, describe=True)
        self._sync()

        if prepared:
            assert isinstance(self.read_message(), PgParseComplete)

        assert isinstance(self.read_message(), PgBindComplete)

        row_desc = self.read_message()
        assert isinstance(row_desc, PgRowDescriptor)

        def yielder():
            while True:
                n = self.read_message()
                if isinstance(n, PgDataRow):
                    row_desc.load_row(n)
                    yield row_desc
                elif isinstance(n, PgPortalSuspended):
                    self._execute(rows)
                    self._sync()
                elif isinstance(n, PgCommandComplete):
                    break

            self.wait_for_state()

        self.in_query = True
        return yielder()
dataset/ETHPy150Open dieseldev/diesel/diesel/protocols/pg.py/PostgreSQLClient.query/original