Send run events to Sqlite
Capturing run events to Sqlite can make searching for answers faster
Last updated
Capturing run events to Sqlite can make searching for answers faster
Last updated
You can easily send your runs metadata to Sqlite as well as to manifest.json
files. Why might you want to do that? Sqlite gives you the ability to quickly search for runs that match certain characteristics. It contains most of the data in the results and result events so you can more easily query at multiple levels across runs.
Turning on the Sqlite backend is simple. It is pre-configured in your generated config/config.ini
, when you create a new project. To add Sqlite to an existing project, pickup the latest version of CsvPath Framework from Pypi and add these to the [listeners]
section of your config.ini
:
Also in [listeners]
, you need to add the sqlite
group to the groups
key. If for some reason you want to, you can run the SqliteResultsListener
without the SqliteResultListener
, but the reverse is not true. I can't think of a reason to just one of the listeners, though.
Finally, you need a [sqlite] section with a single key pointing to the file that will contain the database. This section and key will also be generated in any new config.ini
created by the Framework. Or, you can add it like this, using any location you like:
That's all there is to it. Your events will now be captured to two tables in the database:
named_paths_group_run
instance_run
Recall that we use the terms instance
, identity
, and csvpath
to refer to csvpaths that are managed by a CsvPaths
object. The term instance
stems from the object or instance of the CsvPath
class. Identity refers to the optional but highly recommended ID
or name
metadata field you can add to your csvpath's external comments for better identification in error messages and logging. (E.g. to name a csvpath my csvpath!
do something like: ~ id: my csvpath! ~ $[*][yes()]
)
As you would guess, named_paths_group_run
is the main table describing a run. It is created from the results
event by the SqliteResultsListener
. instance_run
is the description of a csvpath's results within the name-paths group. instance_run
is populated from the result
event handled by SqliteResultListener
.
Just for reference, the schema for the tables is here. You don't have to do anything with it, though. The tables are set up automatically when you enable the integration or anytime you delete the database.
Expanding the model to cover named-paths csvpath group loads and staging named-files is on the roadmap.