Interfaces for legacy vmd files



This function will perform a legacy ‘full table parse’ as one would have done with Chameleon prior to the Translator in a To Database channel.

It takes these parameters:

  • ‘vmd’ – the VMD to use
  • ‘data’ – the message to transform

It returns true values:

  1. A ‘table grammar’ node tree the data parsed from the message in it.
  2. All Python output – i.e. from log and print statements

Here is an example of using it:

local Msg, PythonOutput = chm.parse{ vmd='legacy.vmd', data=Data}

Some caveats:

  • The returned “table grammar tree” (legacy format) is different from the “table tree” returned by db.tables. So if you want to insert a “table grammar tree” into a data base, or compare it to a “table tree” you will need to write helper code to do this.
  • The vmd needs to be part of the Translator project and therefore be under source control.
  • But the python modules the code might use will just be on the general file system

The API is intended to make it convenient to write code to compare the output of equivalent Lua mapping code rather than be an API you would want to use for the long term.

The ability to capture the output from python can be invaluable.

We had a customer that was doing a lot of direct SQL inserts. To make the output of that code visible we did the following:

  • Tweaked the code to override the built in database object to instead print out the SQL statements directly.
  • Parsed the output SQL in Lua to actually create an equivalent table structure which we could then
  • Diff against the equivalent Lua mapping code

Talk to us if you using this API and are curious about more ideas for easily migrating older code.

Leave A Comment?