Generic script for Querying a DB

I have a few databases that i need to get some basic output from... so I'll be returning 1 or 2 records from a variety of different databases and the input queries will always differ.

What im looking for is a generic script that I can use across of the databases. Theory being i have:

mainscript.sh
configfile.cfg

In the config file is things such as db user and pw and type and a list of queries to run.

The mainscript will then go down the config file, connect to the db... run the queries 1 by 1 and echo the output. Obviously the amount of queries and types of databases will vary.

Anyone know of anything already in existance or can think of a funky way of doing this ?!

Any help at all is massively appreciated.

Are the databases all oracle? all sybase? ?

What are the table names? column names? Are they all the same across databases?

It will be both oracle and sybase.... And table names and column names etc will differ. Thats why I want to be able to pass it any query I want and whatever is returned I can output.