Page 1 of 1

dzVents and SQL

Posted: Friday 24 August 2018 1:17
by ChrisKerswell
Hi,

Is there any way to use dzVents to run SQL queries directly on the database?

I tried to search the forum for this but the search ignores "SQL" because it is less than four characters :|

Re: dzVents and SQL

Posted: Friday 24 August 2018 10:16
by waaren
ChrisKerswell wrote: Friday 24 August 2018 1:17 Hi,

Is there any way to use dzVents to run SQL queries directly on the database?

I tried to search the forum for this but the search ignores "SQL" because it is less than four characters :|
Not natively but via popen it can be done

Code: Select all

return {
    
   on = { devices = { "your trigger device" }},
        
  logging =   {   level     =   domoticz.LOG_DEBUG,
                  marker    =   "dataBase query"      },
    
    execute = function(dz)
        local command = 'sqlite3 tempdatabase.db \"select distinct(DeviceRowID) from Temperature_Calendar\" ' 
        local handle = assert(io.popen(command))
        for line in handle:lines() do
            dz.log(line,dz.LOG_DEBUG)
        end
        handle:close()
    end
}