This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Export entire trend log database once
#1
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
Reply
#2
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
Reply


Forum Jump: