Rails 中的多个数据库 [英] Multiple databases in Rails

查看:32
本文介绍了Rails 中的多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这能做到吗?在单个应用程序中,它使用 SQLite 管理许多项目.我想要的是为我的应用程序正在管理的每个项目拥有一个不同的数据库......因此具有相同结构的数据库的多个副本,但其中包含不同的数据.我将根据 URI 上的参数选择要使用的副本.

Can this be done? In a single application, that manages many projects with SQLite. What I want is to have a different database for each project my app is managing.. so multiple copies of an identically structured database, but with different data in them. I'll be choosing which copy to use base on params on the URI.

这样做是为了 1. 安全.. 我是这种编程的新手,我不希望它发生这种情况,因为在处理一个项目时由于某种原因另一个项目被破坏了.. 2. 容易备份和旧项目存档

This is done for 1. security.. I'm a newbe in this kind of programming and I don't want it to happen that for some reason while working on a Project another one gets corrupted.. 2. easy backup and archive of old projects

推荐答案

Rails 默认不是为多数据库架构设计的,在大多数情况下,它根本没有意义.但是是的,您可以使用不同的数据库和连接.

Rails by default is not designed for a multi-database architecture and, in most cases, it doesn't make sense at all. But yes, you can use different databases and connections.

以下是一些参考资料:

这篇关于Rails 中的多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆