Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 355 Bytes

send-a-command-to-psql.md

File metadata and controls

23 lines (18 loc) · 355 Bytes

Send A Command To psql

You can send a command to psql to be executed by using the -c flag

$ psql -c "select 'Hello, World!';"
   ?column?
---------------
 Hello, World!
(1 row)

Specify a particular database as needed

$ psql blog_prod -c 'select count(*) from posts;'
 count 
-------
     8 
(1 row)

h/t Jack Christensen