您可以使用同一数据库切换编程语言吗
假设我有一个完整构建的Python/Django网站。我现在想使用Ruby在Rails或其他一些语言上重新创建该网站。这可以保留相同的数据库吗?还是我必须在两个数据库之间传输数据?
Say I have a python/Django website fully built. I now want to re-create that website with Ruby on Rails or some other language. Is this possible to keep the same database? Or would I have to transfer data between the two databases?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,可以将相同的数据库保留在您从旧应用程序中使用的新应用程序中。您甚至可以让多个应用程序使用与同一时间相同的数据库。
但是,您不应该将所有内容移植到查询上。旧应用程序中可能有一些微妙之处很容易错过...逻辑通常希望生活在数据库中的地方而不是生活在应用程序中。关于数据库结构的决定也可能有可能容纳旧环境的怪癖或能力,而对新环境来说不再有意义。
结果是您可能还可以创建服务层的常见点。使用服务层, 应用程序都不会直接与数据库进行对话。取而代之的是,他们都与介导DB访问的服务应用程序进行了交谈。
这个新的服务层有助于确保业务逻辑在应用程序之间保持一致,而无需在两个平台之间漂移。它有助于避免重复工作。它通过为诸如Heroku缓存层之类的明显位置创建一个明显的位置来帮助性能,并通过使跨多个服务器的数据访问更加易于扩展数据。
Yes, it is possible to keep the same database in the new application that you used from the old. You can even have multiple applications use the same database as the same time.
However, you should not just port everything over query for query. There are likely subtleties in the old application that will be easy to miss... places where logic one would normally expect to live in the database instead lives in the application. There are also likely decisions regarding database structure that were made to accommodate quirks or abilities of the old environment that no longer make sense for the new.
The result is this a common point where you might also create a service layer. With a service layer, neither application talks to the database directly. Instead, they both talk to a service application that mediates access to the DB.
This new service layer helps make sure business logic is consistent across applications, without drifting between the two platforms. It helps avoid duplicating work. It helps with performance by creating an obvious place for things like a heroku caching layer, and by making it easier to scale data access across multiple servers.