I am faced with the task of iterating through a substantial set of MS Access databases (*.MDB) files and, without knowing anything about their schema, writing out an XML file containing all of the table contents. The idea being that I can then run a search engine spider over the resulting XML files such that I can locate databases on the file system. This is part of a data discovery tool used for risk management.

I am seeking the wisdom of fellow monks with this task because I believe that I am not the only one to have needed to do this. I am also looking for an example of how to discover the schema of an MS Access database.

The plan so far:

  1. Scan the network drive for *.mdb files using File::Find.
  2. Create / update and ODBC DSN for each database file using Win32::ODBC to manage the conection.
  3. Open a connection to the database using DBI and the DBD::ODBC driver.
  4. Discover the schema - This is where I need some information!
  5. Iterate over the tables, rows, columns. Write out to an XML file using XML::Writer.

Any help on the 'Discover the Schema' bit would be most appreciated.


In reply to Flattening Access DB to XML by inman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.