Database Export Module
Overview
Database Export Module provides real-time export of data received from devices to popular databases. Supported DBMS are Microsoft SQL Server, Oracle, PostgreSQL and MySQL. The module is included in the Rapid SCADA distribution and does not require separate installation. The following figure shows the form for configuring the module.
The module supports export to several different databases in parallel. The database to which the export is performed is called the export target. Based on the export target options, the module creates an exporter, a software object that processes data queues and calls SQL queries.
Information about the module operation is recorded in the ModDbExport.log
file. Information about the operation of each exporter is written in ModDbExport_*.log
and ModDbExport_*.txt
files.
Configuring
To open the module configuration form, go to the Server > Modules page, select the ModDbExport module and click the Properties button. The module should be in the list of active modules. The module configuration is saved in the ModDbExport.xml
file.
Add a new export target to the module configuration using the button, selecting the DBMS from the drop-down list. Next, let's look at the pages containing various groups of export target settings. The screenshots below show the default parameter values.
Specify the Command code if users plan to manually send commands to export archives. Set the Status channel number to monitor the export status via the web interface. A channel of the Calculated type should be created in the configuration database. Channel values: 0 - normal, 1 - error. The queue options are set experimentally depending on the amount of exported data and the performance of the database server.
A database into which the export is performed must be previously created and contain tables for storing information. The options for connecting to the database should be clarified with its administrator. If the database server is deployed on a separate computer, the server's firewall settings must be configured to allow incoming connections on the TCP port being used.
Current data can be exported On Receive by Server from Communicator or On Timer. Transferring data when received ensures that all current data received from the polled devices is uploaded to the database. Transferring data by timer reduces the database size and saves network traffic.
Historical data export refers to data that is transferred with a timestamp, such as:
- Archives that are downloaded by Communicator from metering devices and transferred to Server.
- Data received from Rapid Gate Module installed on a remote server when replicating archives.
The Delay before export option helps the exporter accumulate some amount of historical data to transfer it in one transaction, which is more efficient. The Bit of historical archive is used to retrieve data from the calculated channels.
Archive replication ensures that the information in the Rapid SCADA archive and in the database is identical. If archive replication is enabled and the Automatically export archives checkbox is checked, historical data and events received by the Server service from clients are not added to the export queue to avoid duplication. The replication state is saved while the module is running and is loaded when the Server service is restarted.
The figure above shows the options of the SQL query that is called by the exporter when Server receives the corresponding data or when replicating the archive. The link contains scripts for creating a database model and sample queries. SQL queries can contain parameters, which are specified with the @
prefix. To view a list of available parameters depending on the request data kind, click the button.
If the Single query checkbox is unchecked, the SQL query will be called for each channel whose data is processed. The request parameters for exporting the channel value and status are @val
and @stat
.
If the Single query checkbox is checked, the SQL query will be called once only for those channels whose numbers are explicitly specified in the query filter. In this case, the names of the channel value and status parameters contain the channel number, for example, @val101
and @stat101
.
Queries that have the Single query checkbox checked are ignored:
- If current data is exported on receive.
- When exporting historical data received from clients.
Commands
Database Export Module supports receiving commands. To send commands to the module, create output type channels in the configuration database. The Tag code of the channel must match the Command code specified in the general export target options. A command can be sent via the Webstation application web interface or using another client interacting with the Server application.
When a valid command is received, a task is created and added to the exporter task queue. The maximum length of a task queue is 10. If the queue is full, new commands will be ignored.
Example of archive export command:
cmd=ExportArchive
startDT=2025-12-31 10:00:00
endDT=2025-12-31 11:00:00
Clear the exporter task queue:
cmd=ClearTaskQueue
The command arguments specify UTC time.