|
GolcondeExamples
Code examples and example flow
Featured Application FlowThe following is the basic application and message flow for Golcode operation:
Code ExamplesPythonimport stomp, json
'''
Given the following schema:
CREATE TABLE test ( user_id int4 primary key, status text );
'''
# Connect to our stomp broker
connection = stomp.Connection([('127.0.0.1', 61613)])
connection.start()
connection.connect()
# Add a row
command = {'action': 'add', 'data': { 'user_id': 1, 'status': 'Hello World' }}
connection.send(destination='/queue/golconde.test', json.dumps(command))
# Update a row
command = {'action': 'update', 'restriction': {'user_id': 1}, 'data': { 'user_id': 1, 'status': 'Status Updated' }}
connection.send(destination='/queue/golconde.test', json.dumps(command))
# Delete a row
command = {'action': 'delete', 'restriction': {'user_id': 1}}
connection.send(destination='/queue/golconde.test', json.dumps(command))
# Set a row - Upsert
command = {'action': 'set', 'restriction': {'user_id': 1}, 'data': { 'user_id': 1, 'status': 'Another Status' }}
connection.send(destination='/queue/golconde.test', json.dumps(command))
# Another set
command = {'action': 'set', 'restriction': {'user_id': 1}, 'data': { 'user_id': 1, 'status': 'We updated this time' }}
connection.send(destination='/queue/golconde.test', json.dumps(command))
|
► Sign in to add a comment