A
A
Alexey2013-11-30 20:47:46
MySQL
Alexey, 2013-11-30 20:47:46

How to parse xml in mysql?

There is an XML file which is updated from time to time. This XML file needs to be parsed into the database. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dzuba, 2013-11-30
@ale-eex

This can be done with mysql alone.
Loading XML into a table: LOAD XML
Periodic run (built-in cron): Event Scheduler (don't forget to enable it
event_scheduler=ONin the muscle config). See also: post .
If there is no root access to the server, then just call via cron:

mysql -u <имя_пользователя_mysql> --password=<пароль> -e "LOAD XML ...;"

T
Tyranron, 2013-11-30
@Tyranron

Um, write a script and run cron periodically, or write a daemon that itself will periodically climb into the xml file and overtake the deltas into the database. How, where and what - already depends on the xml structure and the structure of the tables in the database.
Language of your choice: PHP, Python, Ruby, Perl, Golang, and many others...
If you use the daemon option, you can also implement the filesystem notifications option, that is, hang a listener on the file, and when it changes, the daemon will immediately parse the deltas in the database. This option seems to me the most optimal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question