MySql query result usage

#1

Hello everyone! I’m using flow xo for the first time and I’m facing a lot of troubles. I solved most of them but I still have a problem: I’m running this query on a MySql database:

and getting this as a result:

Result
{
“rows”: [],
“fields”: [
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “DonorID”,
“orgName”: “DonorID”,
“charsetNr”: 255,
“length”: 120,
“type”: 253,
“flags”: 20483,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “DonorFirstName”,
“orgName”: “DonorFirstName”,
“charsetNr”: 255,
“length”: 80,
“type”: 253,
“flags”: 4097,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “DonorLastName”,
“orgName”: “DonorLastName”,
“charsetNr”: 255,
“length”: 80,
“type”: 253,
“flags”: 4097,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “Address”,
“orgName”: “Address”,
“charsetNr”: 255,
“length”: 800,
“type”: 253,
“flags”: 20483,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “MapURL”,
“orgName”: “MapURL”,
“charsetNr”: 255,
“length”: 2000,
“type”: 253,
“flags”: 4097,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “FoodType”,
“orgName”: “FoodType”,
“charsetNr”: 255,
“length”: 80,
“type”: 253,
“flags”: 20483,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “Quantity”,
“orgName”: “Quantity”,
“charsetNr”: 255,
“length”: 80,
“type”: 253,
“flags”: 20483,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “ExpirationDate”,
“orgName”: “ExpirationDate”,
“charsetNr”: 63,
“length”: 10,
“type”: 10,
“flags”: 20611,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “Charity”,
“orgName”: “Charity”,
“charsetNr”: 255,
“length”: 80,
“type”: 253,
“flags”: 0,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “Pending”,
“orgName”: “Pending”,
“charsetNr”: 63,
“length”: 1,
“type”: 1,
“flags”: 1,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
},
{
“catalog”: “def”,
“db”: “aimi_db”,
“table”: “Donations”,
“orgTable”: “Donations”,
“name”: “Collected”,
“orgName”: “Collected”,
“charsetNr”: 63,
“length”: 1,
“type”: 1,
“flags”: 1,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
}
]
}

What does rows[] mean? Is this an empty result? I tried to run the same query directly on the database and I get all the rows that I expect.

And then, when I have the result of the query, how can I address each attribute in the raw body in “make a HTTP request”?
Thank you
Pietro

(Daniel Beckett) #2

Hi @umotrus,

The data is whatever is returned from your MySQL query and will be available as a Data Output. You can insert particular pieces of the data into your webhook.

Are there certain fields that you need to pick out to include in your webhook?

#3

Hi @DanielBeckett, thank you! I know that the data is what is returned and the format is that one, but I don’t understand the meaning of the result code: am I getting any rows from it? I’ve already read that page but I still have doubts: should I write something like {{run_a_query.result__rows__0__attribute1}} to retrieve the attribute1 in row 0?
thanks

(Daniel Beckett) #4

It doesn’t look like you’re returning any row data.

For the data that is being returned, sites like http://json.parser.online.fr/ can help. Makes the data a lot easier to read and work with :slight_smile:

You can see that all of your returned data is part of an array inside of ‘fields’. These will increment for each block starting at 0 like so:

If you wanted data from the ‘table’ field from the first part of the array (0) then you would use:
{{run_a_query.result__fields__0__table}}

I’m guessing that the bigger issue here is that the data you’re being returned doesn’t match what you expect? This can be tricky to troubleshoot as unfortunately MySQL queries fall a bit outside my area of expertise.

#5

Thanks, that’s the answer I was looking for :slight_smile:
I was expecting something like this but I wasn’t sure: the problem is not in the HTTP request but in the “run a query”.
I’m quite familiar with MySQL but I know nothing about web programming and JSON (thank you for the parser link, it will be very useful). I ran the query directly in the MySQL database and obtained the right set of rows, how is it possible that the result in here is different? I probably made a mistake in that part of the flow, but I cannot figure out which one it could be :sob: