This activity provides your flogo application execute database queries in MySQL. Currently only select queries are supported.
https://github.com/go-sql-driver/mysql
https://github.com/jmoiron/sqlx
flogo install github.com/fm-tibco/mysql_activity
Input and Output:
{
"input":[
{
"name": "dataSourceName",
"type": "string",
"required": true
},
{
"name": "query",
"type": "string",
"required": true
},
{
"name": "params",
"type": "object"
},
{
"name": "columnTypes",
"type": "params"
}
],
"output": [
{
"name": "results",
"type": "array"
}
]
}
Setting | Description |
---|---|
dataSourceName | The db connection string |
query | The db query statement |
params | Optional - Params for named db query |
columnTypes | Optional - The types of the columns |
{
"id": "dbquery",
"name": "DbQuery",
"activity": {
"ref": "github.com/fm-tibco/mysql_activity",
"input": {
"dataSourceName": "username:password@tcp(host:port)/dbName",
"query": "select * from test"
}
}
}
{
"id": "named_dbquery",
"name": "Named DbQuery",
"activity": {
"ref": "github.com/fm-tibco/mysql_activity",
"input": {
"dataSourceName": "username:password@tcp(host:port)/dbName",
"query": "select * from test where id > :id",
"params": {
"id":1
}
}
}
}
If type cannot be determined for a returned column, the value will default to string. In order to fix this you can specify an optional "columnTypes" to specify the type of the column.
{
"id": "dbquery",
"name": "DbQuery",
"activity": {
"ref": "github.com/fm-tibco/mysql_activity",
"input": {
"dataSourceName": "username:password@tcp(host:port)/dbName",
"query": "select * from test",
"columnTypes" : {
"id":"integer"
}
}
}
}