Logic Machine Forum
Export entire trend log database once - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Export entire trend log database once (/showthread.php?tid=844)



Export entire trend log database once - spyder - 17.06.2017

Dear experts,

I would like to export the entire trend log in a csv file once.

However, I wonder what would be the easiest solution?
1) using the visual interface - I can only seem to select 1 day or 1 week and then export every single day manually?
2) using a script with trend log function - how can I run a script once? e.g. https://forum.logicmachine.net/showthread.php?tid=313
3) using a call to /scada-main/trends/fetch to get json
4) using a script with direct db export db:getall('SELECT * FROM trends ORDER BY name DESC') - is this possible?

What would be the easiest to get all the data with the highest resolution?

Thanks,

Kristof


RE: Export entire trend log database once - admin - 19.06.2017

You can get a list of all trends via a db request, then you can call fetch:
Code:
require('trends')
names = db:getlist('SELECT name FROM trends')

dates = {}
dates['start'] = os.date('*t')
dates['start'].year = dates['start'].year - 1
dates['end'] = os.date('*t')

for _, name in ipairs(names) do
  data = trends.fetch(name, dates)
end