how to connect to database in drupal in order to display the content in a table I am using drupal in order to create a website on my localhost machine.

I have a mysql database that i want to connect it  to the drupal website and display its data in a table.

and in the drupal I download the Views Database Connector (VDC) module in order to  connect to the external database.

but it did not work .

second method  I used views and created content types that are the fields table of the  external databases.

but I do not know how to continue to display the data.

third method  I created the tables in drupal database and want to display  its content .

I am new to drupal so I want  any of these method to  work for me 

note  feeds module  also did not work because its not set up yet on the drupal 8.x
You need add the followings lines in settings.php for connecting 'external' database.

$databases['default']['default'] = array(
      'database' =&gt; 'drupal8',
      'username' =&gt; 'username',
      'password' =&gt; 'password',
      'prefix' =&gt; '',
      'host' =&gt; 'localhost',
      'port' =&gt; '3306',
      'namespace' =&gt; 'Drupal\\Core\\Database\\Driver\\mysql',
      'driver' =&gt; 'mysql',
    );

$databases['external']['default'] = array(
  'database' =&gt; 'external',
  'username' =&gt; 'username',
  'password' =&gt; 'password',
  'prefix' =&gt; '',
  'host' =&gt; 'localhost',
  'port' =&gt; '3306',
  'namespace' =&gt; 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' =&gt; 'mysql',
);


To activate external database

\Drupal\Core\Database\Database::setActiveConnection('external');


//code to fetch data and display

To activate drupal database

\Drupal\Core\Database\Database::setActiveConnection();


If you are looking some example refer How to connect to another database in your Drupal 8 site ?