How to enqueue a list of tuples using the Python Client API

How to enqueue a list of tuples using the Python Client API

book

Article ID: KB0076351

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

I have a field in my schema that is a list of tuples. How can I set the value of this field using the Python Client API?

Resolution

StreamBase tuples map to Python dictionaries, and StreamBase lists map to Python lists.

For example, given the Input Schema for an input stream named BidsIn
<schema name="schema:BidsIn" uuid="C335B2728CBCBFD791A7BB86D024B5AD">
<field description="" name="bids" type="list">
<element-type type="tuple">
<schema uuid="EF44BB76767F7028D9EF4D3A62BF750A">
<field description="" name="Price" type="double"/>
<field description="" name="Volume" type="int"/>
</schema>
</element-type>
</field>
</schema>
use the following syntax to enqueue:
client = sb.Client("sb://localhost")
client.enqueue("BidsIn", {'bids': [ {'Price': 10.0, 'Volume': 100}, {'Price': 5.0, 'Volume': 50}]})
client.close()


For details on Python Dictionaries, refer to chapter 3 of the Python Language Reference.

Issue/Introduction

How to enqueue a list of tuples using the Python Client API