Hi,
I have a large XML file that conforms to a well defined schema that I need to import in a mysql database.
The database is fairly complex, consisting of several tables with various keys and what not and additionally I will need some logic during the import process. For example I will need to compare the dates on an XML node and say if there is already a database entry matching this node, then only insert if the date element is newer than the one in the database. So I will have to query the database before each insert to obtain keys/IDs etc.
My current idea is to write some Python to traverse the XML document and basically build up objects for everything and then query the database with the required logic and do the SQL inserts/updates.
Guess I just want to check if this is the best way to do the import, where some logic checks / key calculations etc are required during the import process.
Maybe there's a better method? I know MySQL has some kind of XML import functionality, but I don't think it's applicable here as I won't be able to just blindly import everything in the XML document.
I have a large XML file that conforms to a well defined schema that I need to import in a mysql database.
The database is fairly complex, consisting of several tables with various keys and what not and additionally I will need some logic during the import process. For example I will need to compare the dates on an XML node and say if there is already a database entry matching this node, then only insert if the date element is newer than the one in the database. So I will have to query the database before each insert to obtain keys/IDs etc.
My current idea is to write some Python to traverse the XML document and basically build up objects for everything and then query the database with the required logic and do the SQL inserts/updates.
Guess I just want to check if this is the best way to do the import, where some logic checks / key calculations etc are required during the import process.
Maybe there's a better method? I know MySQL has some kind of XML import functionality, but I don't think it's applicable here as I won't be able to just blindly import everything in the XML document.