I have a table in Postgresql which has 3 columns - c_uid, c_defaults and c_settings. c_uid simply stores the name of a user and c_defaults is a long text string which has a lot of data w.r.t that user.
I have to execute a statement from a bash script which selects the value of the c_defaults column based on the c_uid value and this needs to be done as postgres user.
On the CLI,
[mymachine]# su postgres
bash-4.1$psql
postgres=#\c database_name
You are now connected to database "database_name" as user "postgres".
database_name=#SELECT c_defaults FROM user_info WHERE c_uid = 'testuser';
How do I achieve this through a bash script?
The aim is to get the information from that column, edit it and write it back into that column - all through a bash script.