home-assistant-variables
home-assistant-variables copied to clipboard
DB records into attribute array
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