...
Code Block | ||
---|---|---|
| ||
#PARSER PQL
#QUERY
input = ACCESS({
source=’Source’,
wrapper=’GenericPull’,
transport=’File’,
protocol=’CSV’,
datahandler=’Tuple’,
options=[
[’filename’, ’C:\Users\Daniel\Desktop\Test\Testdaten\cityInf.csv’],
[’delay’, ’1’]
],
schema=[[’id’, ’Integer’],[’data’, ’String’]]
}
)
s01 = WSENRICH({
servicemethod=’REST’,
method=’GET’,
url=’http://api.geonames.org/countryInfo?lang=it&’,
urlsuffix=’&username=demo&style=full’,
arguments=[[’country’, ’data’]],
datafields=[
[’//countryCode’, ’String’],
[’//countryName’, ’String’],
[’//isoNumeric’, ’Integer’]
],
parsingMethod=’XPATH’,
outerJoin=’false’,
caching=’true’,
cacheSize=100,
expirationTime=300000,
removalStrategy=’FIFO’
},
input
)
TODO: XML-RPC example |
A simple example for an xml-rpc based communication:
Server is from here:
https://docs.python.org/3/library/xmlrpc.server.html
Code Block | ||
---|---|---|
| ||
from xmlrpc.server import SimpleXMLRPCServer
from xmlrpc.server import SimpleXMLRPCRequestHandler
# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
# Create server
with SimpleXMLRPCServer(('localhost', 8000),
requestHandler=RequestHandler) as server:
server.register_introspection_functions()
# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)
# Register a function under a different name
def adder_function(x, y):
return x + y
server.register_function(adder_function, 'add')
# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'mul').
class MyFuncs:
def mul(self, x, y):
return x * y
server.register_instance(MyFuncs())
# Run the server's main loop
server.serve_forever() |
For this, the following (rather silly) odysseus query can be used.
Code Block |
---|
#PARSER PQL
#RUNQUERY
timer = TIMER({
period = 1000,
source = 'timer'
}
)
mapped = MAP({
expressions = [
['1','a'],
['1','b']
],
keepinput = false
},
timer
)
enriched = WSENRICH({
url = 'http://localhost:8000/RPC2',
servicemethod = 'XML-RPC',
datafields = [['result', 'Integer']],
arguments = [['1','a'],['2','b']],
operation = 'add'
},
mapped
) |
an creates the following output