Answers.Body: <p>Do it exactly like was done in Drupal 7..
  You should be able to goto path: civicrm/admin/setting/uf?reset=1</p>
  <p>And then copy the integration code for the settings.php or settings.local.php from the &quot;Views Integration settings&quot;</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-10T12:17:36.630Z
Answers.Text: 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.
Answers.UserDisplayName: Pál Rudan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-10T22:03:49.400Z
Answers.Text: This looks like Drupal DB user, set in settings.php trying to query CiviCRM database but not having permissions to SELECT on it.
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-11T13:39:43.423Z
Answers.Text: 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.
Answers.UserDisplayName: Pál Rudan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-12T08:43:57.303Z
Answers.Text: Could happen, that this https://github.com/eileenmcnaughton/civicrm_entity/issues/259 issue has some relation with my problem?
Answers.UserDisplayName: Pál Rudan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-19T08:48:49.500Z
Answers.Text: 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.
Answers.UserDisplayName: Pál Rudan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-21T17:50:54.687Z
Answers.Text: That `SELECT command denied` error was solved for me & others by [Views integration error on D9 #4](https://www.drupal.org/project/civicrm_entity/issues/3198146#comment-14035717):
  
  "Try removing the back ticks ... '`' from the prefix information in the settings.local.php"
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-27T18:34:33.287Z
Answers.Text: Right, for now removing the backticks works, Drupal 9 still hasn't deprecated per-table prefixes, but may come one day.
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-09T20:26:21.047Z
Answers.LastActivityDate: 2021-02-09T20:26:21.047Z
Answers.UserDisplayName: jackrabbithanna
Body: <p>On based the answers on this question <a href="https://civicrm.stackexchange.com/questions/27768/how-to-get-civicrm-views-to-work-in-drupal-8-with-separate-civicrm-database">How to get CiviCRM Views to work in Drupal 8 with separate CiviCRM database</a> 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).</p>
  <p>I put a second <code>$databases['civicrm']['default'] = array {......};</code> to the end of my <code>settings.php</code> file with the correct informations, but on the Views preview page I get always the <code>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxxxDEVxxxxx.civicrm_contact' doesn't exist: SELECT &quot;civicrm_contact&quot;.&quot;modified_date&quot; AS &quot;civicrm_contact_modified_date&quot;, &quot;civicrm_contact&quot;.&quot;id&quot; AS &quot;id&quot; FROM {civicrm_contact} &quot;civicrm_contact&quot; ORDER BY &quot;civicrm_contact_modified_date&quot; DESC LIMIT 11 OFFSET 0; Array ( ) </code> error -- xxxxxDEVxxxxx is my Drupal9's database.</p>
  <p>Is it possible somehow the get Views work? Thank You!</p>
  
Tags: <drupal-views><civicrm-entity><settings><drupal-9>
Title: How to get Views to work in CiviCRM on Drupal9 with separate CiviCRM database
ThreadText: # How to get Views to work in CiviCRM on Drupal9 with separate CiviCRM database
  
  (Asked by: username_0 on 2021-02-09)
  
  On based the answers on this question [How to get CiviCRM Views to work in Drupal 8 with separate CiviCRM database](https://civicrm.stackexchange.com/questions/27768/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!
  
  **Tags:** drupal-views, civicrm-entity, settings, drupal-9
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-02-09. Score: 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"
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: This looks like Drupal DB user, set in settings.php trying to query CiviCRM database but not having permissions to SELECT on it.  
  > **username_0**: 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.  
  > **username_0**: Could happen, that this https://github.com/eileenmcnaughton/civicrm_entity/issues/259 issue has some relation with my problem?  
  > **username_0**: 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.  
  > **username_2**: That `SELECT command denied` error was solved for me & others by [Views integration error on D9 #4](https://www.drupal.org/project/civicrm_entity/issues/3198146#comment-14035717):  "Try removing the back ticks ... '`' from the prefix information in the settings.local.php"  
  > **username_1**: Right, for now removing the backticks works, Drupal 9 still hasn't deprecated per-table prefixes, but may come one day.  
  
  ---
  
  