Cannot run dazl introductury example
App Development3 posts361 views1 likesLast activity Nov 2021
GY
gyorgybalazsiOP
Nov 2021I’d like to run the following introductory example from the dazl documentation:
import asyncio
import dazl
async def main():
async with dazl.connect(url='localhost:6865', read_as='Alice') as conn:
async for event in conn.creates():
print(event.contract_id, event.payload)
# Python 3.7+ or later
asyncio.run(main())
See dazl.ledger
On ‘localhost:6865’ a sandbox is running.
I get the following error message:
line 6, in main
async for event in conn.creates():
AttributeError: 'Connection' object has no attribute 'creates'
What am I doing wring?
DT
dtanabe
Nov 2021My apologies: the docs are incorrect.
The correct version is this:
import asyncio
import dazl
async def main():
async with dazl.connect(url='localhost:6865', read_as='Alice') as conn:
async with conn.query('*') as stream:
async for event in stream.creates():
print(event.contract_id, event.payload)
# Python 3.7+ or later
asyncio.run(main())
We’ll update the docs as well. Thanks for bringing this to our attention!
GY
gyorgybalazsi
Nov 2021Perfect, thank you!