Recorder (mysql)
Warning
This page contains features that are unfinished, were never implemented, or have since been deprecated. We preserve these pages for archival purposes, and also as a foundational resource for prospective developers who may wish to implement the same or similar feature. Many of these pages provide robust explanations of the theory behind a particular module or feature that we hope readers will find useful.
This page does not reflect the current state of GridLAB-D™
The mysql recorder is designed to be compatible the the tape recorder object so that when the mysql module is used in place of the tape module, there are few changes, if any, required to the recorder objects.
Synopsis
module mysql;
object recorder {
property property-name;
trigger condition;
table|file source-table;
mode {"w","w+","a","a+"};
limit max-rows;
interval seconds;
connection database-object-name;
options PURGE|UNITS;
datetime_fieldname "t";
recordid_fieldname "id";
header_fieldnames "";
recorder_name "recorder_name";
group "group-identifier";
query_buffer_limit max-query-buffer;
minimize_data boolean;
custom_sql "custom_sql";
}
Description
| Parameter | Description |
|---|---|
| connection | Specifies the database object used to connect to MySQL. If none is provided, the last database defined is used. |
| datetime_fieldname | Specifies the field name to use for the date-time field in stored records. The default is "t". |
| file | A synonym for table for compability with recorder file. |
| filetype | Provided for compability with tape player and has no real effect. |
| header_fieldnames | Specifies the header data to store in each record inserted. The default is none (i.e., ""). Valid fields are "name", "class", "latitude", "longitude". The values are comma-delimited. Name is limited to 64 characters, class is limited to 32 characters, and latitude/longitude are doubles conforming to ISO Standard 6709. |
| interval | Specifies the sampling interval. By default the interval is specifies in seconds, but if units are specifies conversion will be automatic. |
| mode | Specifies the read mode to use, which may be either "w", "w+", "a", or "a+". If "w" or "w+" is used, the table is purged before data from the current run is added. If "a" or "a+" is used, the data from the current run is appended. |
| options | Specifies the recorder options, as follows: PURGE: Purges the table of all existing data (by dropping and recreating the table) before storing new data. UNITS: Adds the internal units to the field name when the property does not already specify the desired units. |
| property | Specifies the property (or properties) that are to be recorded. The property name can include units, in which case conversion is automatically performed when the value is posted. Properties may also include object names, in which case the parent is ignored and the property is read from the specified object instead. Parts of complex properties can be referenced using the object.part syntax, and will be stored as object_part in the database. |
| recordid_fieldname | Specifies the record id field name to use when adding records to a table. The default is "id". |
| group | The group identifier to activate group mode for the recorder. See Finding Objects for object searching. Note: using this mode disables custom header_fieldnames, and will always enable the "name" field. |
| query_buffer_limit | The maximum number of database insertions to buffer before submitting the values. The default is 200. |
| table | Specifies the source table from which data is read. |
| trigger | Specifies the triggering condition for starting the recording. |
| recorder_name | A string (default) or unsigned small int (minimize_data) parameter that activates an additional column in the output database, printing the string in each output generated by the writing recorder. This feature can be used to uniquely identify the source recorder when multiple recorders write to a single table. |
| minimize_data | A boolean parameter which activates data size minimization mode. Data minimization does the following data shrinks: * Converting CHAR data types to VARCHAR (same write speed, marginally slower read when used as filter parameter) * Converting DOUBLE to FLOAT * Converting the recorder_name field type from a VARCHAR to a SMALLINT UNSIGNED * Disabling all indexes except the Primary Key |
| indexcustom_sql | A string parameter which allows the manual insertion of an arbitrary number of custom, fixed value columns into MySQL. The formatting is parameter_name PARAMETER_DATA_TYPE parameter_value and may contain multiple comma-separated sets of data. 1. flag BIT 1: inserts a column called flag of type BIT into the database and gives it value '1' for each row. 2. flag BIT 1, word VARCHAR(10) 'example': inserts the same column as example 1, but additionally adds a column called word of type VARCHAR(10) containing the word example for each row. |
Bugs
- The limit is not enforced until at least one row is added. Therefore, it is likely that after a given run, the number of rows is increased by 1 even though the maximum number of rows has been reached.
Related Concepts:
- mysql module
- database class
- recorder class
- player class
- collector class
- MySQL Import/Export
- Technical manuals
- Programmer's manual
- MySQL How To Guide