There is sqlSyncHis func that helps to get history from sql tables.
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
(sqlConn, his, dateTimeRange)
Each proxy record must define:
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.
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.
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: