首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Windows98/ME > 将MySQL数据库直接转换为XML文件Shell脚本
【标  题】:将MySQL数据库直接转换为XML文件Shell脚本
【关键字】:MySQL,XML,Shell
【来  源】:http://www.cublog.cn/u/23177/showart.php?id=179188

将MySQL数据库直接转换为XML文件Shell脚本

用java写不胜其烦,得连接数据库,得用jdom转换XML文件,用Shell写只有下面几行:

# /usr/local/bin/mysql2xml
TMP_FILE=tmp.txt
RESULT_FILE=slot.xml

mysql -uroot -p1983228 -e"use ontology; select d.DB_Owner, a.DB_Tab, a.DB_Attr, b.SlotName, b.SlotID, c.NodeName, c.NodeID from slot_db a, slot b, node c,
db_info d where a.SlotID=b.SlotID and a.NodeID=c.NodeID and a.DB_ID=d.DB_ID order by d.DB_Owner, DB_Tab;" --default-character-set=utf8 > $TMP_FILE

# 删除字段名称
sed -i '1d' $TMP_FILE

awk 'BEGIN{print "<Slot_DB>"}
          {print "  <Item>"}
          {print "    <DB_Owner>",$1,"</DB_Owner>"}
          {print "    <DB_Tab>",  $2,"</DB_Tab>"}
          {print "    <DB_Attr>", $3,"</DB_Attr>"}
          {print "    <SlotName>",$4,"</SlotName>"}
          {print "    <SlotID>",  $5,"</SlotID>"}
          {print "    <NodeName>",$6,"</NodeName>"}
          {print "    <NodeID>",  $7,"</NodeID>"}
          {print "  </Item>"}
       END{print "</Slot_DB>"}' $TMP_FILE | tee $RESULT_FILE

rm -f $TMP_FILE
20061001(国庆节加班):【上一篇】
Soalris10 上用bind 9.2.4架设dns服务器:【下一篇】
【相关文章】
  • linux下配置APACHE2.0.50+PHP5.0.3+MYSQL4.0.20+GD库
  • Windows平台下PHP5.0+Mysql4.1.x环境架设(2)
  • Windows平台下PHP5.0+Mysql4.1.x环境架设(3)
  • Windows下PHP5.x+MYSQL4.1.x开发·工作环境的架设(5)
  • Windows下PHP5.x+MYSQL4.1.x开发·工作环境的架设(6)
  • Ajax:拥抱JSON,让XML走开
  • XML在电子商务中的应用
  • mysql的选项文件(my.cnf)的搜索顺序
  • 从MySQL得到最大的性能
  • redhat linux9.0下配置APACHE2.0.55 +PHP5.1.1+MYSQL5.0.
  • 【随机文章】
  • 程序员的能力系列题目更名的声明
  • Ajax Form Post
  • iframe 自动适应高度
  • C++学习笔记之“动态数组”
  • 低级文件I/O
  • Composite UI Application Block - December 2005 Release
  • Tomcat性能优化(5)
  • Recipe 1.3. Substituting Variables into an Existing String
  • 服务器的分类(下)
  • java学习中重写与重载方法的区别(转自:小鸟的天空)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.