Logic Machine Forum
Export Alert list to CSV or email - 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 Alert list to CSV or email (/showthread.php?tid=2742)



Export Alert list to CSV or email - iJAF - 23.07.2020

Hello,

Is there any way to export the current Alert list to a CSV file or to send it via email ?

Thank you


RE: Export Alert list to CSV or email - admin - 24.07.2020

Here's how to get CSV for alerts:
Code:
rows = { '"Date/time","Script name","Message"' }
items = db:getall('SELECT * FROM alerts ORDER BY id DESC')

for _, item in ipairs(items) do
  datetime = os.date('%c', item.alerttime)
  rows[ #rows + 1 ] = string.format('%q,%q,%q',
    datetime, item.scriptname, item.alert)
end

csv = table.concat(rows, '\n')



RE: Export Alert list to CSV or email - Frank68 - 11.02.2021

(24.07.2020, 06:32)admin Wrote: Here's how to get CSV for alerts:
Code:
rows = { '"Date/time","Script name","Message"' }
items = db:getall('SELECT * FROM alerts ORDER BY id DESC')

for _, item in ipairs(items) do
  datetime = os.date('%c', item.alerttime)
  rows[ #rows + 1 ] = string.format('%q,%q,%q',
    datetime, item.scriptname, item.alert)
end

csv = table.concat(rows, '\n')
the best solutions is create a csv file and sent via mail, the same for register object


RE: Export Alert list to CSV or email - Frank68 - 12.02.2021

(11.02.2021, 14:53)Frank68 Wrote:
(24.07.2020, 06:32)admin Wrote: Here's how to get CSV for alerts:
Code:
rows = { '"Date/time","Script name","Message"' }
items = db:getall('SELECT * FROM alerts ORDER BY id DESC')

for _, item in ipairs(items) do
  datetime = os.date('%c', item.alerttime)
  rows[ #rows + 1 ] = string.format('%q,%q,%q',
    datetime, item.scriptname, item.alert)
end

csv = table.concat(rows, '\n')
the best solutions is create a csv file and sent via mail, the same for register object
Hello

If I wanted to create a scheduled script on the first of the month and choose only the alarms of the previous month as is the select string, I can use the where? with a part of the date?

Thank you