How do I connect Prestashop with an external database?

hello I am creating a module to connect from prestashop with an external database. It is on the same server but it is a different database from prestashop. I am using this code that should show the product name with id = 1 in the right sidebar. I have tried a hello world and it shows it without problems, but for some reason when trying to connect with the external database the page does not show me anything. This is the code for the hook function that should show me the name of the product in the right sidebar, what’s wrong?