Search code examples
mysqlsqlsql-serverjsonmediawiki

Convert SQL dump to JSON?


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?


Solution

  • 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?

    enter image description here

    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.