How can I switch to an external db with Views API? In Drupal 7 I have a module with a hook_form(). This form is saving data into an external postgresql database.

I want to create a views to display data recorded. So I used hook_views_data() to create a mapping between the view and my custom tables. I created a view with admin but in this view I have the following error : 

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cars' doesn't exist


I have tried something like this but it doesn't run :

function carshop_views_pre_render(&amp;$view) {
  if ($view-&gt;name == 'cars_overview') {
    db_set_active('carsdb');
  }
db_set_active();
}
Sounds as if you need the Views Database Connector module.

From the project page:


  Views Database Connector is a powerful module that gives Views full access to external database tables found in the settings for your Drupal installation. With this module, you can setup a view around any table in any database configuration. This can be extremely useful to pull external data from a database to show to your users in a view.