Skip to content
Advertisement

Execute sql queries from shell script

I need to execute the following sql queries from bash/expect script what is the preferred approach to run these queries from bash script

for access PostgreSQL we do

and when we run this ( /tmp/file include the bach of the query )

we get

Advertisement

Answer

I’m using this

Then run sql script from file

Or from query var

Also pgpass can be set in special file ~/.pgpass like this

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement