관리 메뉴

Sysops Notepad

[DB] mysql/mariadb json format export output 본문

업무/etc

[DB] mysql/mariadb json format export output

sysops 2018. 11. 20. 06:42
728x90

mysql/mariadb 리눅스 json 포멧으로 출력하는 방법


# echo "select * from table limit 3;" | mysqlsh --json --sqlc --uri root@ip:3306

{"duration":"0.00 sec","info":"","row_count":3,"rows":[[1,"PENELOPE","GUINESS",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[2,"NICK","WAHLBERG",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[3,"ED","CHASE",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}]],"warning_count":0}


echo "select * from table  limit 3;" | mysqlsh --json=raw --sqlc --uri root@ip:3306

{"duration":"0.00 sec","info":"","row_count":3,"rows":[[1,"PENELOPE","GUINESS",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[2,"NICK","WAHLBERG",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}],[3,"ED","CHASE",{"year":2006,"month":1,"day":15,"hour":4,"minute":34,"second":33.0}]],"warning_count":0}


echo "select * from table  limit 3;" | mysqlsh --json=pretty --sqlc --uri root@ip1:3306

{

    "duration": "0.00 sec",

    "info": "",

    "row_count": 3,

    "rows": [

        [

            1,

            "PENELOPE",

            "GUINESS",

            {

                "year": 2006,

                "month": 1,

                "day": 15,

                "hour": 4,

                "minute": 34,

                "second": 33.0

            }

        ],

        [

            2,

            "NICK",

            "WAHLBERG",

            {

                "year": 2006,

                "month": 1,

                "day": 15,

                "hour": 4,

                "minute": 34,

                "second": 33.0

            }

        ],

        [

            3,

            "ED",

            "CHASE",

            {

                "year": 2006,

                "month": 1,

                "day": 15,

                "hour": 4,

                "minute": 34,

                "second": 33.0

            }

        ]

    ],

    "warning_count": 0

}



참고 : https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-json-output.html

728x90
Comments