Executing Redshift queries using Psql

We've seen that we can connect to our database with the following Psql command:

$ psql -h amlpackt.cenllwot8v9r.us-east-1.redshift.amazonaws.com -p 5439 -U alexperrier --password -d amlpacktdb

We then need to type in our password. To shorten the line and avoid having to type the password each time, we can set both the connection string and the password as shell environment variables. In your terminal, execute the following command to create a global REDSHIFT_CONNECT shell variable:

$ export REDSHIFT_CONNECT='-h amlpackt.cenllwot8v9r.us-east-1.redshift.amazonaws.com -p 5439 -U alexperrier -d amlpacktdb'

Similarly for the password, execute the command:

$ export PGPASSWORD=your_password

From now on, ...

Get Effective Amazon Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.