[Sussex] Extracting data from MySQL into XML format
Steve Dobson
steve at dobson.org
Sun Jul 10 08:51:48 UTC 2005
Hi John
Thanks for the reply.
On Sun, Jul 10, 2005 at 09:21:01AM +0100, John Crowhurst wrote:
> On Sun, July 10, 2005 8:36, Steve Dobson said:
> > Hi guys
> >
> > Does anyone know of a tool that will extract data from a MySQL
> > database and wrap it in XML. I need to provide a "select" query
> > to reduce the data going into the XML file, and of course it needs
> > to be command line callable so I can script it.
>
> Would perl be an option here?
>
> You could use XML::Generator::DBI to read from your MySQL database and
> wrap it into XML from your select statement.
Not really as that would mean having to write the wrapper code, and I
don't know perl. However I do know php and I can do something simular
there.
> I know mysqldump can export as XML, you can specify both the database and
> table, but it doesn't support select statements. You can supply a WHERE
> statement but you can't use select to limit the fields you wish to export.
>
> mysqldump --user=user --pass=pass --xml --where="id>2" dbname tablename
This is more like it. I didn't know that mysqldump supported XML. The
limitation of no support for the select is not a problem 'cos I want
all fields anyway.
> > I also, of course, need a tool that takes the XML and inserts it
> > into another database.
>
> Under perl you could use XML::XMLParser to read in the XML and extract the
> fields from it, you'd then insert them into your table.
>
> This page has an example of importing and exporting XML from MySQL:
> http://www.kitebird.com/articles/mysql-xml.html
Now I need the same for php. There must be some - yet (Google is my
friend).
Ta
Steve
--
Chef, n.:
Any cook who swears in French.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20050710/5deade6f/attachment.pgp
More information about the Sussex
mailing list