I've got a question associated with some guidances to resolve an issue. I've beside me an xml file, I must populate it right into a database system (whatever, it may be sqlite, mysql) using scripting language: Python.

Does anybody have idea regarding how to proceed?

  • Which technologies I have to read further?
  • Which conditions I must install?
  • Any lessons on a single subject?

I already attempted to parse xml using both by tree-based and sax method in other language, but to begin with Python, I'm not sure how to start. I already realize how to create the database I want.

Another question, is Python alone possible of performing database ddl queries?

I suggest you study on ElementTree for parsing your XML file into memory (parse everything, then emit everything to some SQL DB, is most likely simpler, but element-tree also enables incremental operation in case your file is big) -- it's area of the standard Python library as module xml.etree.

I suggest sqlite3 (also within the standard Python library) because the relational DB of preference (for those who have an option), again since it is handy and simple -- the actual SQLite embedded relational DB can also be well recorded at its own site. Should you prefer a general tutorial how Python loves to interface to relational DBs (the "DB-API"), there is a nice one here.

When you completely understand etree and sqlite3 -- and also you don't always have to install *any*factor for either (that is a part of their charms-) -- you are essentially ready. (Obviously a set up of SQLite itself (commandline and/or GUI tools) so you can try your DB files and tweak them might be nice, as may graphical XML editors for example oXygen or XMLmindto check out and/or tweak your XML, but neither type of tool is whatsoever needed, not whatsoever associated with using Python instead of other languages for that XML parsing and SQLite writing-).

Company, you are able to perfectly well do CREATE TABLE along with other DLL queries from sqlite3 (and then any other DB-API compliant Python module, if you opt to use other relational DBs-).

If you're familiar with DOM (tree) use of xml using their company language, you might find helpful these standard library modules (as well as their particular paperwork):

  • xml.dom
  • xml.dom.minidom

In order to save tha data to DB, you should use standard module sqlite3 or search for binding to mysql. Or else you may decide to use some thing abstract, like SQLAlchemy or Django's ORM.