Connecting to a Remote SQL Database Using G Web Development Software

Updated Aug 23, 2023

Reported In

Software

  • LabVIEW NXG Web Module
  • LabVIEW NXG
  • LabVIEW

Issue Details

I want to be able to connect to an SQL database with an application created with the G Web Development Software and present the data by reading SQL tables/records from the database. How can I do this?

Solution

There are no direct database communication functions from within Web VIs created with the G Web Development Software, however, there are some options utilizing other functions within LabVIEW in conjunction with Web VIs.

Web Services

Create a web service that handles the database communication, then use the WebVI to send HTTP requests to the web service to update/acquire database information like the following:

You can create the web service through LabVIEW and use the LabVIEW Database Connectivity Toolkit to interface with the database and perform basic database operations to read and write data. For an example of communication between LabVIEW Web Services and LabVIEW Web VIs, refer to this GitHub example. Keep in mind that while these are two separate entities (Web Service and Web VI), you can still have everything on the same computer by hosting the web service, and using the Web VI build output as static files in the web service. The previous links are LabVIEW specific, but the same principle should apply to any other web service. For more information on using existing web services, refer to the Additional Information section.

Additional Information

You can also use an existing web service that already communicates to an SQL database. Some suggestions that may work for these purposes include PostgRest or restSQL. The process would be similar to the above instructions using HTTP VIs as the bridge between the Web VI and the database