From GridLAB-D Wiki
Jump to: navigation, search

recorder (mysql) - MySQL recorder class Template:NEW30

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";  New in 4.0! 
  recordid_fieldname "id";  New in 4.0! 
  header_fieldnames "";  New in 4.0! 
  recorder_name "recorder_name";  New in 4.1! 
  group "group-identifier";  New in 4.1! 
  query_buffer_limit max-query-buffer;  New in 4.1! 
  minimize_data boolean;  New in 4.1! 
  custom_sql "custom_sql";  New in 4.1! 
}

Description

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.

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".  New in 4.0! 

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.  New in 4.0! 

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.  New in 4.0! 
Parts of complex properties can be referenced using the object.part syntax, and will be stored as object_part in the database.  New in 4.1! 

recordid_fieldname

Specifies the record id field name to use when adding records to a table. The default is "id".  New in 4.0! 

group

The group identifier to activate group mode for the recorder. See Finding Objects for object searching.  New in 4.1! 
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.  New in 4.1! 

table

Specifies the source table from which data is read.

trigger

Specifies the triggering condition for starting the recording. See recorder trigger for details.

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.  New in 4.1! 

minimize_data

A boolean parameter which activates data size minimization mode. Data minimization does the following data shrinks:  New in 4.1! 
  • 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 index

custom_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.  New in 4.1! 
  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.

Version

The mysql player was introduced in Hassayampa (Version 3.0).

See also