O'Reilly logo

Effective Amazon Machine Learning by Alexis Perrier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required