Convert SQL dump to JSON?

▼魔方 西西 提交于 2019-12-11 05:55:52

问题


I have a SQL dump from MediaWiki and I want to export it to JSON - I've tried different ways but I can't seem to find any solution. The sql-file looks like this:

DROP TABLE IF EXISTS `geo_tags`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `geo_tags` (
  `gt_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `gt_page_id` int(10) unsigned NOT NULL,
  `gt_globe` varbinary(32) NOT NULL,
  `gt_primary` tinyint(1) NOT NULL,
  `gt_lat` decimal(11,8) DEFAULT NULL,
  `gt_lon` decimal(11,8) DEFAULT NULL,
  `gt_dim` int(11) DEFAULT NULL,
  `gt_type` varbinary(32) DEFAULT NULL,
  `gt_name` varbinary(255) DEFAULT NULL,
  `gt_country` binary(2) DEFAULT NULL,
  `gt_region` varbinary(3) DEFAULT NULL,
  PRIMARY KEY (`gt_id`),
  KEY `gt_page_primary` (`gt_page_id`,`gt_primary`),
  KEY `gt_page_id_id` (`gt_page_id`,`gt_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4507036 DEFAULT CHARSET=binary ROW_FORMAT=DYNAMIC;

Followed by a few lines with INSERT INTO.

INSERT INTO `geo_tags` VALUES (3,487781,'earth',1,59.00000000,10.00000000,1000,NULL,NULL,NULL,NULL)

Whenever I try to import the sql file into an SQL nothing happens. Is there any easy solution to convert my data to JSON?


回答1:


Posting as an answer as I can't post the image in the comments. http://www.csvjson.com/sql2json seems to work fine with several lines. Maybe it has some limit?

How many records are you trying to insert?

UPDATE Rockstar Martin Drapeau, the guy behind csvjson.com, just implemented my feature request, so now mysqldump INSERT syntax will work on his website. Try it here.



来源:https://stackoverflow.com/questions/39216133/convert-sql-dump-to-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!