Read from MySQL

From XdmfWeb
Jump to navigationJump to search

Accessing a MySQL DataBase

Note SQL support was removed in xdmf 3.

Partial support for reading data from a MySQL database is available. MySQL is treated as another HeavyData format like HDF5. Currently database access is ReadOnly and is accessed by setting the Format of the DataItem in XML equal to MySQL

           <Attribute Name="Cell Centered Values" Center="Cell">
               <DataItem Format="MySQL"
                   Server="localhost"
                   User="root"
                   DataBase="MnmiFromout"
                   Dimensions="3"
                   NumberType="Float">
                   <![CDATA[SELECT X FROM Locations WHERE Time < 0.21]]>
               </DataItem>
           </Attribute>

A Valid SQL statement is placed in the CDATA of the DataItem. When the XdmfDataItem is updated, an atomic query is made and the result is placed in the XdmfArray of the DataItem. Putting a "<" (less than) in the CDATA will cause an error in the XML parser. The XML example above shows how to do this correctly.

The Server, User, and DataBase attributes tell Xdmf how to access MySQL. There is also a Password attribute. Currently this is just clear text which is a really bad idea. This will change.