[erlang-questions] How to convert sql return data to json

Kenneth Lakin <>
Mon Sep 4 22:59:46 CEST 2017

On 09/01/2017 05:36 AM, Palanikumar Gopalakrishnan wrote:
> *for checking Sql result {{metadata,2,0,
> {server_status,false,true,false,false,true,
> false,false,false,false,false,false,false},
> [{field_metadata,"def","zurik","erlang",
> "erlang","name","name",33,135,253,
> <<0,0>>,0,[]},
> {field_metadata,"def","zurik","erlang",
> "erlang","id","id",63,11,3,
> <<0,0>>,0,[]}],[]},
> [["some",457],["some",457],["data2sosfasfme",42]]}*

So, it *looks* like your driver is returning a tuple containing:
* A 'metadata' record which contains (among other things) a
server_status record and a list of field_metadata records.
* A list containing the data that is the response to your query.

The "Getting Started" section of the erlmysql documentation [0] seems to
say that the record definitions that you need are contained in
"client_records.hrl". Loading that file into your Erlang shell with the
rr/1 shell command and re-running the query should make the SQL driver's
return value make more sense to you.

In order to load those record definitions into your client code, you'll
probably need to do something like


near the top of the file that needs to interact with the SQL driver.

[0] http://erlmysql.sourceforge.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170904/545744af/attachment.bin>

More information about the erlang-questions mailing list