home-assistant-variables icon indicating copy to clipboard operation
home-assistant-variables copied to clipboard

DB records into attribute array

Open gerliczky opened this issue 4 years ago • 0 comments

It would be nice, when the content of a database table could be selected into an array of arrtibutes in a variable. It would be also useful to add an optional db_url parameter to be able to use external database.

Like: DB:

colA colB
cell1 cell2
cell3 cell4

Code:

var:
  db_table_to_attribute_array:
    db_url: db_url
    query: select colA, colB from table

Result:

data:
- colA: cell1
  colB: cell2
- colA: cell3
  colB: cell4

gerliczky avatar Jul 08 '20 03:07 gerliczky