On based the answers on this question How to get CiviCRM Views to work in Drupal 8 with separate CiviCRM database I'm trying to get work Views on Drupal9. Drupal9 and CiviCRM has different databases, but the database user who is trying to work with the databases has access for both databases, and I installed CiviCRM Entity module (the latest Drupal8 version).

I put a second $databases['civicrm']['default'] = array {......}; to the end of my settings.php file with the correct informations, but on the Views preview page I get always the SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxxxDEVxxxxx.civicrm_contact' doesn't exist: SELECT "civicrm_contact"."modified_date" AS "civicrm_contact_modified_date", "civicrm_contact"."id" AS "id" FROM {civicrm_contact} "civicrm_contact" ORDER BY "civicrm_contact_modified_date" DESC LIMIT 11 OFFSET 0; Array ( ) error -- xxxxxDEVxxxxx is my Drupal9's database.

Is it possible somehow the get Views work? Thank You!

1 Answer 1


Do it exactly like was done in Drupal 7.. You should be able to goto path: civicrm/admin/setting/uf?reset=1

And then copy the integration code for the settings.php or settings.local.php from the "Views Integration settings"

  • A bit better, but still not working... I get a new error message: Drupal\Core\Database\DatabaseExceptionWrapper type: Exception in xxxViewNamexxx[xxxBlockNamexxx]: SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'xMyCiviCRMUserx'@'localhost' for table 'civicrm_contact': SELECT [...] message Drupal\views\Plugin\views\query\Sql->execute() function (/var/www/devweb/web/core/modules/views/src/Plugin/views/query/Sql.php file in line 1548.). (in the section [...] is a simple query, but it's too long for pasting here. xMyCiviCRMUserx has access to the db.
    – Pál Rudan
    Feb 10, 2021 at 12:17
  • This looks like Drupal DB user, set in settings.php trying to query CiviCRM database but not having permissions to SELECT on it. Feb 10, 2021 at 22:03
  • The Drupal DB user is the same as the CiviCRM user. Checked by me and by the DB manager too, and the DB User has ALL PRIVILEGES on both DB's.
    – Pál Rudan
    Feb 11, 2021 at 13:39
  • Could happen, that this github.com/eileenmcnaughton/civicrm_entity/issues/259 issue has some relation with my problem?
    – Pál Rudan
    Feb 12, 2021 at 8:43
  • It seems so, that CiviCRM Entity (at least up to CiviCRM Entity 8.x-3.0-beta2 version) not handles, if Drupal and CiviCRM are in separate databases.
    – Pál Rudan
    Feb 19, 2021 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.