magento 2 in object manager using database connect code example
Example: magento 2 get connection
$om = \Magento\Framework\App\ObjectManager::getInstance();
$connectionO = $om->create('Magento\Framework\App\ResourceConnection');
$connection= $connectionO->getConnection();
$sql = 'some query';
$results = $connection->fetchAll($sql);