简体   繁体   中英

The best way to connect application to MySQL database

I have a general question of what is the best way to connect a production app to a database server. So, I am planning to make an application which will need to have a direct connection to MySQL database. Database itself will be hosted in the same building on dedicated server with no access from outside world (Network). My question is. Will I use some type of REST service or I can make a direct connection from my application to the database server using SSL encryption? The other question is, there is a possibility that we say 2 more sites will need to have a direct connection to that database is well. In this case can I use VPN connection with SSL without REST service and make all the requests in my code in functions?

You can use sqlalchemy to connect directly to the data base and use its ORM , so you'll do everything programmatically.

But i would say that good practise is to create a RESTfull API and make calls to your db through that API. There is a good library Sandman which might help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM