将SQL转储转换为JSON吗? [英] Convert SQL dump to JSON?

查看:77
本文介绍了将SQL转储转换为JSON吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自MediaWiki的SQL转储,我想将其导出到JSON-我尝试了不同的方法,但似乎找不到任何解决方案. sql文件看起来像这样:

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;

接着用 INSERT INTO 插入几行.

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

每当我尝试将sql文件导入到SQL中时,都不会发生任何事情.有什么简单的解决方案可以将我的数据转换为JSON?

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

推荐答案

发布为答案,因为我无法在评论中发布图像. http://www.csvjson.com/sql2json 似乎可以用几行正常工作.也许有一些限制?

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?

您要插入几条记录?

更新 csvjson.com背后的人Rockstar Martin Drapeau刚刚实现了我的功能请求 ,因此mysqldump 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.

这篇关于将SQL转储转换为JSON吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆