I have CiviCRM 4.7.28, Drupal 7.56 and Views 7.x-3.18 and have CiviCRM and Drupal in the same database.

I have read in the documentation that Views should work out of the box, and most of the issues relating to CiviCRM and Views is to configure setup if CiviCRM and Drupal are on different databases.

Any tip much appreciated!

  • Can you be more specific about what you mean by "not working"?
    – choster
    Dec 22, 2017 at 22:12
  • When I go into Views, I don’t any CiviCRM tables to select
    – Flying
    Dec 22, 2017 at 22:18
  • when you go to create a new view, are you given any civicrm options in the top menu? (Show:) if you are in a view that is not based in a civicrm contact/activity/etc. you should also be able to see civi options when adding a new Relationship, do you have those options?
    – ericG
    Dec 23, 2017 at 0:25
  • @ericG no, I have no CiviCRM options on the top menu
    – Flying
    Dec 23, 2017 at 0:56
  • strange. I've never had a problem with this. even though they are in one db, maybe try to put the section in the config file anyway? worth a try. /civicrm/admin/setting/uf?reset=1 will give you the info to paste into the settings.php file
    – ericG
    Dec 24, 2017 at 1:29

3 Answers 3


Perhaps you missed this step: https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/

  1. Before making any changes, it is strongly advised that you make backups of your mysql databases and settings.php file.
  2. If you have different database users for your CiviCRM and Drupal databases, then you need to grant SELECT access for the Drupal user to all the CiviCRM tables.
  3. Make sure you are logged into your Drupal site as the administrator.
  4. Visit http://example.org/civicrm/admin/setting/uf?reset=1
  5. You should see a page with output that begins with: $databases['default']['default']['prefix']= array(
  6. Copy this setting output, including the trailing );
  7. Open /sites/default/settings.php for editing from the root directory of the site, typically public_html on most servers.

    Note: This assumes you have a single site installation. The location of the settings file might be different depending on whether or not you have multiple sites

  8. Find the database connector array. This is where Drupal stores the information regarding the MySQL database and the necessary credentials to connect to it. The array beings with $databases = array ( then goes on to include the location and MySQL credentials, as well as additional options.
  9. Paste your previously-copied settings output here. Be sure to paste it after the trailing );
  10. You may need to indicate the default prefix. If you see an error [like] PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'kckruppc_every.semaphore' doesn't exist: SELECT ... You need to include an additional line, 'default' => '<drupaltableprefix>', in your settings.php just after $database ['default']['default']['prefix']= array(. …
  11. Save the file. You might want to clear your site cache at this point.
  12. You should now be able to create views based on CiviCRM data.

As a test you could install the CiviCRM Entity module, that provides views integration in a different way than core. If that doesn't work then something strange is happening for sure


Like KarinG said, there is a step needed to tell Drupal about CiviCRM's database tables. That is described at https://docs.civicrm.org/sysadmin/en/latest/integration/drupal/views/. This involves editing your Drupal settings.php file and pasting code provided by CiviCRM.

This has worked well for me, and I have this working on a live site right now. Some of the queries you can run with this in Views are a bit limited compared to native Drupal node queries, but it does work.

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.