DB API for shell scripting (any shell)
Posted
by
foampile
on Programmers
See other posts from Programmers
or by foampile
Published on 2012-11-27T02:30:57Z
Indexed on
2012/11/27
5:28 UTC
Read the original article
Hit count: 354
I am faced with some legacy shell scripts that run batch data processing jobs in Oracle using SQL+
. For the most part, the data tier does not have to communicate back to the script with retrieved data to be passed for shell-level processing but in a few cases it does.
The problem is, SQL+ is really meant to be an end user app and not an API that can communicate with other clients programmaticaly. That is why people have invented APIs such as DBD::DBI
for Perl, JDBC
for Java, ODBC etc. The way it is done is they invoke SQL+ and then parse the output, which is clearly designed for human eye consumption, using tools like sed
and awk
. The whole thing is at best a hack and very prone to bugs.
Since this client is rather conservative with their technology, they don't want to scale their scripts up to Perl or Python where there are data access APIs. So I am wondering whether there are similar APIs for shell, e.g. K or bash. What I would like is if an API would return data in a 2-dimensional array or strings (for the lack of type setting) so that I can just read DB data like that.
The way they do it now is akin to parsing regular web page HTML to get a single stock quote rather than cleanly calling a web service and be done with it.
Anybody know of a product I can use? Thanks
© Programmers or respective owner