Today I Learned

hashrocket A Hashrocket project

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!';"
 Hello, World!
(1 row)

Specify a particular database as needed

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

h/t Jack Christensen

See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.