At a time of creating this script, all messages exported from Facebook were placed in single html file and all pictures were placed in single directory. This made it difficult to view the data. This script extracts all metadata from there and saves it to database in order to let user run SQL scripts on it. It also organizes pictures into folders.
Data format provided by Facebook might change since then; compare it to this template to check if script is still usable.