postgresqlbashdockercommandexec

Select value from table? Bash


I want to extract the value of ID in a single command, I think this is a table but i'm not sure.

                  id                  
--------------------------------------
 00000000-0000-0000-00000-00000000000

I get this ID from a table in a docker container of postgres and I want to get only the value in a single command, I use this command to obtain the table:

docker exec -it container psql -U postgres -d database --command="SELECT id FROM table WHERE name='device_name';

Different things that I saw on internet.


Solution

  • Use This Command

    docker exec -it container psql -U postgres -d database --tuples-only --no-align --command="SELECT id FROM table WHERE name='device_name';"