Path: blob/master/tools/perf/Documentation/db-export.txt
26282 views
Database Export1===============23perf tool's python scripting engine:45tools/perf/util/scripting-engines/trace-event-python.c67supports scripts:89tools/perf/scripts/python/export-to-sqlite.py10tools/perf/scripts/python/export-to-postgresql.py1112which export data to a SQLite3 or PostgreSQL database.1314The export process provides records with unique sequential ids which allows the15data to be imported directly to a database and provides the relationships16between tables.1718Over time it is possible to continue to expand the export while maintaining19backward and forward compatibility, by following some simple rules:20211. Because of the nature of SQL, existing tables and columns can continue to be22used so long as the names and meanings (and to some extent data types) remain23the same.24252. New tables and columns can be added, without affecting existing SQL queries,26so long as the new names are unique.27283. Scripts that use a database (e.g. exported-sql-viewer.py) can maintain29backward compatibility by testing for the presence of new tables and columns30before using them. e.g. function IsSelectable() in exported-sql-viewer.py31324. The export scripts themselves maintain forward compatibility (i.e. an existing33script will continue to work with new versions of perf) by accepting a variable34number of arguments (e.g. def call_return_table(*x)) i.e. perf can pass more35arguments which old scripts will ignore.36375. The scripting engine tests for the existence of script handler functions38before calling them. The scripting engine can also test for the support of new39or optional features by checking for the existence and value of script global40variables.414243