Answers.Body: <p>It is possible, you can code it (and because you are a scripter I suppose you are a coder). In CiviCRM, the views settings are generated in the with file <a href="https://github.com/civicrm/civicrm-core/blob/master/CRM/Admin/Form/Setting/UF.php" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/master/CRM/Admin/Form/Setting/UF.php</a> </p>
  
  <p>I used this as inspiration to create the following script</p>
  
  <pre><code>&lt;?php
  $config = CRM_Core_Config::singleton();
  $dsnArray = DB::parseDSN($config-&gt;dsn);
  $tableNames = CRM_Core_DAO::getTableNames();
  $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
  $tablePrefixes .= "\n  'default' =&gt; '$drupal_prefix',"; // add default prefix: the drupal database prefix
  $prefix = "";
  if ($config-&gt;dsn != $config-&gt;userFrameworkDSN) {
    $prefix = "`{$dsnArray['database']}`.";
  }
  foreach ($tableNames as $tableName) {
    $tablePrefixes .= "\n  '" . str_pad($tableName . "'", 41) . " =&gt; '{$prefix}',";
  }
  $tablePrefixes .= "\n);";
  
  echo $tablePrefixes;
  </code></pre>
  
  <p>Run this script with the CiviCRM <code>cv</code> utility (see <a href="https://github.com/civicrm/cv" rel="nofollow noreferrer">https://github.com/civicrm/cv</a>) as follows.</p>
  
  <pre><code>cv scr &lt;scriptname.php&gt;
  </code></pre>
  
  <p>I tested this on CiviCRM 4.7.27</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-10T19:21:35.187Z
Answers.Text: Cool! I will try this and let you know!
Answers.UserDisplayName: ñull
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-10T19:10:04.960Z
Answers.LastActivityDate: 2018-01-10T19:10:04.960Z
Answers.UserDisplayName: Kainuk - CiviCooP
Body: <p>Is there a way to output from the command line the views integration settings as listed in Administer > System Settings > CMS Database Integration? I need this as part of our upgrade script to automatically update settings.php (rewriting a php include file) every time a system upgrade is released. </p>
  
Tags: <drupal-views><developer>
Title: How to extract views integration setting from the command line?
ThreadText: # How to extract views integration setting from the command line?
  
  (Asked by: username_0 on 2018-01-10)
  
  Is there a way to output from the command line the views integration settings as listed in Administer > System Settings > CMS Database Integration? I need this as part of our upgrade script to automatically update settings.php (rewriting a php include file) every time a system upgrade is released.
  
  **Tags:** drupal-views, developer
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-10. Score: 1
  
  It is possible, you can code it (and because you are a scripter I suppose you are a coder). In CiviCRM, the views settings are generated in the with file https://github.com/civicrm/civicrm-core/blob/master/CRM/Admin/Form/Setting/UF.php 
  I used this as inspiration to create the following script
  dsn);
  $tableNames = CRM_Core_DAO::getTableNames();
  $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
  $tablePrefixes .= "\n  'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix
  $prefix = "";
  if ($config->dsn != $config->userFrameworkDSN) {
    $prefix = "`{$dsnArray['database']}`.";
  }
  foreach ($tableNames as $tableName) {
    $tablePrefixes .= "\n  '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
  }
  $tablePrefixes .= "\n);";
  
  echo $tablePrefixes;
  
  Run this script with the CiviCRM cv utility (see https://github.com/civicrm/cv) as follows.
  cv scr 
  
  I tested this on CiviCRM 4.7.27
  
  > **Comments:**
  > **username_0**: Cool! I will try this and let you know!  
  
  ---
  
  