ccall database and collect data from one table

I want to connect to one database and collect data from any table using shell script.