Learn AXON

There is sqlSyncHis func that helps to get history from sql tables.


sqlSyncHis

sqlSyncHis(proxies, range)

Import the lastest data from an SQL query into the SkySpark historian database. The proxies may be any value suppored by toRecList.

Each sqlConn record associated by the proxies must define:

  • sqlSyncHisExpr: Axon expression which evaluates to a

    function of (sqlConn, his, dateTimeRange)

Each proxy record must define:

  • sqlConnRef: reference to the SQL connector
  • his: all the standard historized point tags

If the range is unspecified, then an attempt is made to synchronize any data after hisEnd (last timestamp read). If range is unspecified and the history has never been synced, then we only sync last 30 days.

This method is designed to be run in the context of a job via the ext-job::doc.

See ext-sql::doc#syncHis.

Side effects:

  • performs blocking network IO
  • updates sqlHis record with history data
  • updates hisStatus tag transiently
  • updates hisErr tag transiently


Make sure sql connector that you want to use for sync process has sqlSyncHisExpr tag and it is set to function that takes 3 parameters: sqlConn, his, range and returns mapped history data what will be written to his record (example of this function you can see here)

If you use sqlPointId in a sql query in this function make sure points have this tag.


Sync manually

For example to write yesterday history for all points with sqlPointId tag you can run in folio: readAll(sqlPointId).sqlSyncHis(yesterday)

Result will be number of history values written to point:


Sync by job

Also you can make a job and script will run automatically according to set schedule. At "job" expression you shouldn’t pass range to sqlSyncHis function. In this case function gets the data from last sync:



  • No labels