https://docs.mendix.com/howto/data-models/sharing-the-development-database/
You can take a look at these two article/documentation links, I believe they will solve your question!
How Does Mendix Support Direct Access to an External SQL Database
Execute an SQL Statement on an External Database