简体   繁体   English

将应用程序连接到MySQL数据库的最佳方法

[英]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. 因此,我计划制作一个需要与MySQL数据库直接连接的应用程序。 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? 我将使用某种类型的REST服务,还是可以使用SSL加密将应用程序直接连接到数据库服务器? 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? 在这种情况下,我可以在不使用REST服务的情况下使用带SSL的VPN连接,并在函数中的代码中发出所有请求吗?

You can use sqlalchemy to connect directly to the data base and use its ORM , so you'll do everything programmatically. 您可以使用sqlalchemy直接连接到数据库并使用其ORM ,因此您将以编程方式进行所有操作。

But i would say that good practise is to create a RESTfull API and make calls to your db through that API. 但是我会说,好的做法是创建一个RESTfull API,并通过该API对您的数据库进行调用。 There is a good library Sandman which might help you. 有一个很好的图书馆桑德曼 ,可能会帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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