Details
-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
None
-
DOC-2020-S17-Sep06
-
1
Description
Currently there are no asynchronous Python SDK examples within the documentation.
This makes the API very difficult to use as it's not always as simple as just adding a few 'awaits' to the synchronous examples.
We need a page for Python that's similar in scope and style to https://docs.couchbase.com/java-sdk/current/howtos/concurrent-async-apis.html so that users have a starting point for using the async API, even if it does not cover everything.
In case it's at all useful, below is a simple example of using the async API to perform a N1QL query:
import asyncio
|
from acouchbase.cluster import Cluster
|
from couchbase_core.cluster import PasswordAuthenticator
|
|
async def main():
|
conn_str = 'couchbase://10.143.201.101'
|
cluster = Cluster(conn_str, authenticator=PasswordAuthenticator('Administrator', 'password'))
|
await cluster.on_connect() # This will wait until the cluster is connected
|
|
res = cluster.query('select * from `test` limit 1;')
|
async for row in res:
|
print(row)
|
|
if __name__ == "__main__":
|
asyncio.run(main())
|
Attachments
Issue Links
- depends on
-
PYCBC-615 Author documentation on async, concurrent, batching for 'SDK3'
- Resolved
- relates to
-
PYCBC-1012 Add txcouchbase documentation, document applicability vs asyncio
- Open