On Tue, Mar 13, 2018 at 09:49:50AM +0100, Boubaker Idir wrote:
> I want to do a select from my database and to put it in a json file
I strongly recommend Anything But Bash.
You want a language that can connect to whatever database this is...
> #!/bin/bash
> #declare array=$(mysql -u root -pPassword -s -N #<<QUERY_INPUT
... to mysql, and retrieve results into some kind of data structure
(dictionary, list, hash table, whatever). And you also want a language
that can render that data structure (dictionary, etc.) into JSON format.
Bash sucks at both of those. For the JSON piece, there's jq and other
external utilities that you can install, but there is NOTHING you can
do to retrieve SQL results and safely separate them into bash variables
or associative array elements.
https://mywiki.wooledge.org/BashWeaknesses