Async N1QL couchbase query using Twisted API for Python SDK

I am writing a Tornado application and need to create asynchronous N1QL queries. To display map-reducing views using txcouchbase (a twisted couchbase library) worked fine together with the tornado-twisted bridge , but I can't do the same for N1QL queries.

...

from txcouchbase.bucket import Bucket as AsyncBucket
ASYNC_USER_BUCKET = AsyncBucket(**settings.USER_BUCKET_ARGS)

class FooHandler(BaseAPIHandler):
    @schema.validate()
    @authenticated
    @coroutine
    def get(self):
        res = yield ASYNC_USER_BUCKET.n1qlQueryAll("SELECT * FROM farm_user;")
        ...

After executing the following query, the resobject is not iterable and looks as follows. res object

It seems that the field _BatchedRowMixin__rowscontains the results of the query, but I'm not sure if this is the correct and stable way to make async N1QL queries. Are there any other options?

+4

Source: https://habr.com/ru/post/1613024/


All Articles