The script relational_to_xes.py
extracts automatically an IEEE XES event log (please see https://xes-standard.org/) from a relational database using PM4Py 2.2.24, given that:
- The database has a Python connector compliant with Python DB API 2.0. Currently supported DBs are PostgreSQL and SQLite3.
- The database schema is known beforehand and there is no cycle in this schema.
To execute this script, change the following inputs in the code:
db_access_params
: Parameters used to access the databaseannotations
: A list of annotations in the schema. Interface for an annotation is Annotation(table1, key1, table2, key2, annot_type),
which means atributekey1
oftable1
is associated withkey2
oftable2
with the annotation typeannot_type
.annot_type
can be one ofAnnotationType.{ONE_TO_ONE, ONE_TO_MANY, MANY_TO_MANY}
.converter
: Setting up aConverter
object. Parameters are the event table, the case table, activity key, timestamp key, case ID key, and theannotations
.converter.set_database_adapter(DB_NAME)
: ReplaceDB_NAME
with the name or the connector of the database.- In
build_event_log
:- Set the desired exported log name.
- Set the
event_query
. This is a string to define how to extract different acitivity key for each event. General syntax isif {python_expression} then {python_expression} (else if {python_expression})* else {python_expression}
. - Set the default activity, case ID, timestamp if no such attribute is found while extracting the log.
The script extractor.py
is an old version that is not robust against events associated with multiple objects.
The other scripts are suggestions from @Javert899