У меня есть таблица в моей базе данных PostgreSQL, которая имеет 3 столбца - c_uid
, c_defaults
и c_settings
. c_uid
просто сохраняет имя пользователя, а c_defaults
- длинный фрагмент текста, который содержит много данных w.r.t этого пользователя.
Мне нужно выполнить инструкцию из bash script, которая выбирает значение столбца c_defaults
на основе значения c_uid
, и это должно выполняться пользователем postgres пользователя базы данных.
В 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';
Однако, как мне достичь этого с помощью bash script?
Цель состоит в том, чтобы получить информацию из этого столбца, отредактировать ее и записать обратно в этот столбец - через bash script.