Facility Control

 View Only
  • 1.  Using messageBuilder to form and send a SQL-query

    Posted 09-07-2020 20:52

    Hello. Is there possible to use the ogscript.messageBuilder to create a SQL-query which I can then send to my database using either TCP or UDP? Im planning to create a website where the audience of a livestream can participate and contribute to the stream live, and the data are being saved in a database which I want to use in onscreen gfx. I know I can send a HTTP-request to an API who fetch from the database, but want to skip that part if it is possible with the messageBuilder.



  • 2.  RE: Using messageBuilder to form and send a SQL-query

    Posted 09-08-2020 13:46

    What database are you using?

    As far as I know SQL is normally done in plain strings, and not in binary.   So you should not need to use the message builder.   

    You should be able to do something like:

      var sql = "select "

      sql = sql + fields;

      sql = sql + " from "

      sql = sql + tables;

     

    Then send it with something like:

     

      function callback(result) {

        ogscript.debug(results)

      }

      rosstalk.sendMessageWithResponse(sqlhost, sqlport, sql, "\n", callback);

     

    You could do it with messageBuilder, but it feels like overkill to me if all you are dealing with is strings.  I have not sent SQL from DashBoard, so perhaps I am missing something.

     

     


    #DashBoard


  • 3.  RE: Using messageBuilder to form and send a SQL-query

    Posted 09-08-2020 21:57

    Thanks for quick answer!

    I am using MariaDB. I have tried to use the code you sent me, but it doesn't work. It always returns "false". When I query my database using PHP I have to make a MySQL-connection using my username, password, databasename, host and port and I cant see how to fit all those parameters in that sendMessageWithResponse. Is there any way to make such serverconnection in Dashboard so I possibly could take it from there if that exists?


    #DashBoard


  • 4.  RE: Using messageBuilder to form and send a SQL-query

    Posted 09-09-2020 13:36

    Dashboard does not natively support a MySQL connection like PHP does.   

    It might be possible to create a TCP Listener and establish a 2 way communication with your MySQL server.   But you would have to implement the whole authentication scheme which is probably not well documented.   I've never seen anyone do that with DashBoard.   Honestly, I don't think it's the right path forward.

    You mentioned that your database had an HTTP interface, and DashBoard does have HTTP methods that are fairly straight forward.

    You would probably get to where you want faster using those.

     


    #DashBoard


  • 5.  RE: Using messageBuilder to form and send a SQL-query

    Posted 09-09-2020 13:44

    I see. That's what I was afraid of. Thanks anyway!


    #DashBoard