Skip to main content

Worker Python

The Worker-Python executes the provided Python code at the remote worker. More information about the worker at: https://github.com/apioo/fusio-worker-python

Example

def handle(request, context, connector, response, dispatcher, logger):
connection = connector.get_connection('App')
filter = request.arguments.get('filter')

values = []
query = "SELECT id, title, content, insert_date FROM my_blog"
if filter:
query += " WHERE title LIKE ?"
values.append(filter)

cursor = connection.cursor(prepared=True)
cursor.execute(query, values)
result = cursor.fetchall()
cursor.close()

entries = []
for row in result:
entries.append({
'id': row[0],
'title': row[1],
'content': row[2],
'insert_date': row[3],
})

return response.build(200, None, {
'entries': entries
})

Types

This table contains an overview which connection types are implemented and which implementation is used:

TypeImplementation
Fusio.Adapter.Sql.Connection.SqlPyMySQL / pymongo
Fusio.Adapter.Sql.Connection.SqlAdvancedPyMySQL / pymongo
Fusio.Adapter.Http.Connection.Httphttpx.Client
Fusio.Adapter.Mongodb.Connection.MongoDBpymongo
Fusio.Adapter.Elasticsearch.Connection.Elasticsearchelasticsearch

Video