>> home >> support >> documentation >> examples

last update: 05/25/2004

mysql bugs example

In this example, we're going to collect columns from a table on a webpage into a MySQL database, and also write our results to an HTML Report, in five simple steps.


1. First Steps
First, we have to presume that you've got a working MySQL installation, both client and server, availble to you on your machine, although the server may be located on a remotely accessible machine.

In our MySQL examples, we're going to view the MySQL database using the popular PHPMyAdmin tool, running via the built in Apache/PHP and a locally installed MySQL Server.

Here's a link to the source page that we're going to take data from, it's a collection of bugs reported by one of our testers. [Yes, there are probably still bugs in the software, even with these fixed]. We want to collect most of this data, but remove columns that might not be needed for our bug database.


Here's the completed Anthracite Process Chain.


  (click for larger image)


Our database will assign its own bug ID number, so we're going to drop that field, and for this example, we're just going to take the Summary, Description, and Version number, which are columns 1,2,7 when counting starting from column "0" at the left. [KSL:Zero-based]


2. Add Table Processors
So, we set up three table processors where we take table 1 (the only table on the page [KSL:One-based], convert the HTML to an array, then ask for column 1 ("summary"), column 2 ("description"), and column 7 ("version").




Repeat that step for the two additional columns we want to keep: 2 & 7.


3. Configure MySQL Export
Then, once we've set up the table column extractions we want, we're ready to export. Set the Export Object type to MySQL Export, and since we're running on the local machine, we simply configure the query to go to our bugs database ("test.bugs") and the fields will be written based on the input object names ("summary","description","version").



It's just that easy. Read on for the HTML, or jump down to see the MySQL Results.


4. Adding an HTML Report
While we're working on this, we're going to add an HTML report, the "TableRowSnippet" object in the sample document. It's configured as a Template Report with a Custom Snippet

Custom Snippets are bits of HTML that will be replaced and repeated (as needed) to format input data.




In our example, we've got three inputs to work with "summary", "description", and "version" (same as above), so we're going to devise a replacement scheme that substitutes those three values into a table row with double underscores around the names, like so:

<tr><td>__summary__</td><td>__description__</td><td>__version__</td></tr>
		

Then, we use a "wrap" processor to take the output of that report, and wrap it inside a surrounding "table" tag.




Finally, we stuff the output of that into a Results Object and we're ready to run.


5. Run the Process
Run the process (select "Run Process" from the file menu).

First, for the main course, MySQL database entries corresponding to the selected rows from the source HTML table:

  (click for larger image)


But also be sure the check out the:
Sample HTML Output

And note that we've reduced the input table down to just the three columns of interest.

 

[ top ] [ metafy home ]



Copyright © 2004, All Rights Reserved, Metafy LLC