How to use the aiochclient.client.QueryTypes.FETCH function in aiochclient

To help you get started, we’ve selected a few aiochclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maximdanilchenko / aiochclient / aiochclient / View on Github external
def query_type(cls, query: str) -> QueryTypes:
        check = query.lstrip()[:8].upper()
        if any(
            return QueryTypes.FETCH
        if check.startswith("INSERT"):
            return QueryTypes.INSERT
        return QueryTypes.OTHER
github maximdanilchenko / aiochclient / aiochclient / View on Github external
async def _execute(self, query: str, *args) -> AsyncGenerator[Record, None]:
        query_type = self.query_type(query)

        if query_type == QueryTypes.FETCH:
            query += " FORMAT TSVWithNamesAndTypes"
        if args:
            if query_type != QueryTypes.INSERT:
                raise ChClientError(
                    "It is possible to pass arguments only for INSERT queries"
            params = {**self.params, "query": query}
            data = rows2ch(*args)
            params = self.params
            data = query.encode()

        async with
            self.url, params=params, data=data
        ) as resp:  # type: client.ClientResponse
            if resp.status != 200: