0

我正在尝试将两个 xml 文件加载到 mysql 中。两者都有相同的问题。我这里只处理一个。我正在将家里的太阳能和地热数据加载到 msql 中。

这些都不适合我。

mysql> LOAD XML LOCAL INFILE '/var/www/geo-field.xml' INTO TABLE geo; 查询正常,0 行受影响(0.00 秒)记录:0 已删除:0 跳过:0 警告:0

===============

mysql> LOAD XML LOCAL INFILE '/var/www/geo-field.xml' INTO TABLE geo(日期,时间,F2L3_IN,F1L2_OUT,F3L2_IN,F1L2 _IN,F2L1_Middle,F2L3_OUT,F1L2_Middle,F3L3_IN,F2L3_Middle,F2L2_Middle,F1L3_OUT,F2L1_IN ,F3L3_Middle,F3L1_IN,F1 L1_Middle,F3L3_OUT,F2L1_OUT,F1L1_OUT,F1L3_Middle,F2L2_IN,F3L1_Middle,F1L3_IN,F2L2_OUT,F3L2_OUT,F1L1_IN,F3L2_Middle,F3L1_OUT); 查询正常,0 行受影响(0.00 秒)记录:0 已删除:0 跳过:0 警告:0

文件存在

pi@raspi-web:~$ ls -l *.xml rw-r--r-- 1 pi pi 2289 Jun 26 12:30 geo-field.xml

    cat geo-field.xml
   <?xml version="1.0" ?>
    <devices>
          <device>
         <name>date</name>
          <value>06/26/2013</value>
          </device>

          <device>
          <name>time</name>
          <value>11:31:03</value>
          </device>

          <device>
          <name>F2L3_IN</name>
          <value>73.174995</value>
          </device>

          <device>
          <name>F1L2_OUT</name>
          <value>75.199989</value>
          </device>

          <device>
          <name>F3L2_IN</name>
          <value>73.737495</value>
          </device>

          <device>
          <name>F1L2_IN</name>
          <value>75.087501</value>
         </device>

        <device>
         <name>F2L1_Middle</name>
         <value>70.812492</value>
         </device>

        <device>
        <name>F2L3_OUT</name>
        <value>75.424995</value>
      </device>

       <device>
       <name>F1L2_Middle</name>
       <value>71.150001</value>
       </device>

        <device>
      <name>F3L3_IN</name>
       <value>74.074989</value>
       </device>

       <device>
      <name>F2L3_Middle</name>
      <value>70.249992</value>
      </device>

     <device>
     <name>F2L2_Middle</name>
     <value>71.037498</value>
    </device>

    <device>
    <name>F1L3_OUT</name>
    <value>75.199989</value>
   </device>

   <device>
   <name>F2L1_IN</name>
   <value>75.424995</value>
   </device>

   <device>
   <name>F3L3_Middle</name>
   <value>70.137489</value>
   </device>

   <device>
   <name>F3L1_IN</name>
   <value>73.400001</value>
   </device>

   <device>
   <name>F1L1_Middle</name>
   <value>70.924995</value>
   </device>

   <device>
   <name>F3L3_OUT</name>
   <value>74.074989</value>
   </device>

   <device>
   <name>F2L1_OUT</name>
   <value>72.949989</value>
   </device>

   <device>
   <name>F1L1_OUT</name>
   <value>75.424995</value>
   </device>

   <device>
   <name>F1L3_Middle</name>
   <value>71.037498</value>
   </device>

   <device>
   <name>F2L2_IN</name>
   <value>75.312492</value>
   </device>

   <device>
   <name>F3L1_Middle</name>
   <value>69.912498</value>
   </device>

   <device>
   <name>F1L3_IN</name>
   <value>75.537498</value>
   </device>

   <device>
   <name>F2L2_OUT</name>
   <value>72.612495</value>
   </device>

   <device>
   <name>F3L2_OUT</name>
   <value>73.287498</value>
   </device>

   <device>
   <name>F1L1_IN</name>
   <value>75.199989</value>
   </device>

   <device>
   <name>F3L2_Middle</name>
   <value>72.275001</value>
   </device>

   <device>
   <name>F3L1_OUT</name>
   <value>73.062492</value>
   </device>

</devices>
4

1 回答 1

0

您尝试导入的 XML 文件未使用 MySQL 知道如何导入的模式进行格式化。您需要自己转换它。

MySQL 将识别的格式在这里定义:

http://dev.mysql.com/doc/refman/5.5/en/load-xml.html

于 2013-06-26T17:14:31.780 回答