G Web Development Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Get data from MySQL - How would I do that?

Hi,

 

how would I fetch data from a MySQL database? There is no such thing as a DB-Connector in the G Web Development (unlike in LabView).

 

Would I have to use some kind of PHP on my Apache webserver, which would get called via "HTTP Get"? Or do I have to use something else to get Apache to output some kind of JSON format (which I guess would also include PHP)?

 

Edit: I am running XAMPP (Apache + PHP + MySQL on my own server).

 

Thanks for any useful advice.

Martin

0 Kudos
Message 1 of 3
(1,616 Views)

I'm interested to hear what the NI folks have to say, but here's my two cents...

 

It's unusual to talk to the database directly from the front end, which is where the G Web software resides.

More commonly, you have a web service that "wraps" the database calls.  The G Web software would then call this web service API.  Just from a modularity/cohesion/coupling perspective, the front end should not need to know what kind of database is under the hood, nor should it have to know the structure of the database (such as table and column names).  If the frontend knows these things, it's a leaky abstraction.

 

I recently built such a backend (not the leaky kind, but one which abstracts the database).  I have a LabVIEW web service backend built using regular LabVIEW on top of something like SQLite, MySQL, or MariaDB.  This backend defines a relatively simple API for storing and retrieving data.  I defined some simple GETs and POSTs that are application-specific, and data is passed as JSON objects.  (The app logs data from various sensors, and then I am building a G Web frontend to view the data from a web browser.)

 

You can write the backend in any language, of course, but XAMPP sets you up for PHP or Perl.

Brian Powell
Stravaro, LLC


Learn more about the DSH Pragmatic Software Development Workshops.
Message 2 of 3
(1,592 Views)

I wholeheartedly agree with Brian. An excellent tutorial for that can be found here: https://www.studiobods.com/en/niweek2019-ts170/

 

 

0 Kudos
Message 3 of 3
(1,509 Views)