Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Redshift Database from Laravel 5 using Pgsql Driver?

I was wondering if anyone knew whether the above was likely to be achievable or if I'm doing something nonsensical. These connection details work to an RDS (i.e. blah.blah.eu-west-1.rds.amazonaws.com) database:

'db1' => [
        'driver'   => 'pgsql',
        'host'     => env('DB_HOST_BRAIN'),
        'database' => env('DB_DATABASE_BRAIN'),
        'username' => env('DB_USERNAME_BRAIN'),
        'password' => env('DB_PASSWORD_BRAIN'),
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'xyz_admin',
    ],

but these do not work to a Redshift (i.e. blah.blah.eu-west-1.redshift.amazonaws.com) database:

'db2' => [
        'driver'   => 'pgsql',
        'host'     => env('DB_HOST_PINKY'),
        'database' => env('DB_DATABASE_PINKY'),
        'username' => env('DB_USERNAME_PINKY'),
        'password' => env('DB_PASSWORD_PINKY'),
        'port'     => env('DB_PORT_PINKY'),
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'xyz',
    ],

Assuming all the details are correct, is there a compelling reason why this is never going to work? Is there any way I can make it work?

like image 730
thesunneversets Avatar asked Apr 17 '15 15:04

thesunneversets


People also ask

Is Redshift compatible with Postgres?

Amazon Redshift is based on PostgreSQL. Amazon Redshift and PostgreSQL have a number of very important differences that you must be aware of as you design and develop your data warehouse applications.

Does Redshift ODBC driver need Amazon?

You must install the Amazon Redshift ODBC driver on client computers accessing an Amazon Redshift data warehouse.

What is Amazon Redshift ODBC driver used for?

The Amazon Redshift ODBC Driver is a powerful tool that allows you to connect with live Amazon Redshift data, directly from any applications that support ODBC connectivity. Read, write, and update Amazon Redshift data through a standard ODBC Driver interface.


1 Answers

As long as the environment variables are correct, your config works for connecting to Redshift:

$take_over_the_world = DB::connection('db2')->select('SELECT tonight FROM going_to_do');
like image 67
Cameron Avatar answered Sep 21 '22 12:09

Cameron