mycli
mycli copied to clipboard
Select query to JSON
Hey all,
Came here with what I hope is a quick question as I have been trying to get my head around this one now for a few days and I just can't get something, I think quite simple, to work.
I have been able to connect to my MySQL db without issue and I can run queries, but my issue is with the output format.
My query: SELECT COUNT(*) AS 'cnt' FORM table1;
Result is 15
The bit that I'm struggling with is getting it into a JSON format. I'm expecting (or better put.. needing) this...
[{"cnt": "15"}]
I've tried all the available outputs, tried to get it work with the csvkit\csv2json module, but the closest I get is using the CSV formatting, but that's not quite what I'm after!!
Any help on this would be really appreciated! Thank you so much. :)
Hi @MartynKeigher! I was able to get this working for a previous issue and laid out the steps for it here: https://github.com/dbcli/mycli/issues/753#issuecomment-504279817
I hope that works for you!
Hi @MartynKeigher! I was able to get this working for a previous issue and laid out the steps for it here: #753 (comment)
I hope that works for you!
Unfortunately, that only works if you have access to modify the mysql config my.conf