How to receive output data from shell script/database query

[LibreOffice Calc 7.2, MariaDB (but I think this question is somewhat agnostic to the specific SQL version)]

In an earlier question, I needed to work out how to execute a shell script that expected parameters. (How to run 'AppleScriptTask' from LibraOffice Calc?)
In a new application, I now need to be able to receive data into a cell from a query that is based on the contents of other cells in my spreadsheet (i.e. a function).

One way would be to use ODBC, which I have installed and running, to put an SQL query into a cell, though I haven’t worked out how to do this. As an alternate approach, I’m now working on using a macro to perform the query and then put the result into the cell via the macro. However, what I definitely don’t want is to have ODBC access or expose the whole table in the spreadsheet.

Another way would be to collect the output from a shell script (which in this case performs the same query I mentioned above and echoes the result to stdout) and have it entered into a cell via a macro. My understanding though is that com.sun.star.system.SystemShellExecute only returns the exit status of the script.

Has anyone done anything similar?

Hello,

Based on your information about not wanting certain information available, a macro executing the query will be able to do this. See-> Connect to mssql (ODBC) database via Macro.

The Pitonyak Base pdf mentioned there can be gotten here → Andrew Base

Of course using a macro for this requires user & password which can be in the macro. Then you may want to password protect the library. Then you need to have something to trigger the macro. Push button, toolbar item, menu item - something.

Here is one using a URL to a Base file → Is it possible to output cell values directly to base or MYSQL with macro

One with registered Base file (opens access to all Tables and queries) → How do I connect to SQL server in a macro in Windows