Hallo,
ich habe bisher iobroker Daten in eine MsSQL-Datenbank geschrieben und die in einem SQL-Script stark vereinfacht so ausgelesen:
sendTo('sql.0', 'query', 'SELECT 1 AS test;', async(result) =>{setState(DataPoint , getAttr((getAttr(result, 'result')[0]), ''), true); });
und mit
{console.log('### SQL-Test: '+ String(DataPoint) + ' = ' + String(getState(DataPoint).val))};
Das hat funktioniert.
Jetzt habe ich auf MariaDB umgestellt. Daten werden auch problemlos in DB geschrieben. Adapter arbeitet also korrekt und Rechte sind vorhanden.
Ich schaffe es aber nicht mehr auf irgendeine Weise Werte abzurufen. Die ganze SQL-Logik ist in eine DB-function verlegt.
sendTo('sql.0', 'query', "SELECT fnTest AS test;", function(result) {console.log('Result 1: ', result);});
Result bleibt leer. Aber auch folgende Abfragen liefern nichts, bzw 0 zurück:
sendTo('sql.0', 'query', "SELECT 1 AS test;", function(result) {console.log('Result 1: ', result);});
sendTo('sql.0', 'query', "SELECT 1 AS test;", result => console.log('Result 2: ', result));
sendTo('sql.0', 'query', 'SELECT 1 AS test;', result =>{
setState(DataPoint , getAttr((getAttr(result, 'result')[0]), ''), true); });
{console.log('Result3: '+ String(DataPoint) + ' = ' + String(getState(DataPoint).val))};
sendTo('sql.0', 'query', 'SELECT 1 AS test;', async(result) =>{
setState(DataPoint , getAttr((getAttr(result, 'result')[0]), ''), true); });
{console.log('Result4: '+ String(DataPoint) + ' = ' + String(getState(DataPoint).val))};
Hat jemand eine Idee, was ich beim Abruf eines sql mit MariaDB anders machen muss?
Danke im Voraus
Gerd