什么ORM在一个进程中使用多个db连接sinatra应用程序? [英] What ORM to use in one process multiple db connections sinatra application?
问题描述
检查ActiveRecord,DataMapper,Sequel:一些使用全局变量(静态变量)一些需要打开数据库连接之前加载源文件与模型。什么ORM在使用不同数据库的sinatra应用程序中更好。
DataMapper是为多数据库使用而设计的。 p>
只需说出 DataMapper.setup(:repository_one,mysql:// localhost / my_db_name)
。
然后,DataMapper会跟踪您可以引用并用于范围设定的哈希中设置的所有存储库:
DataMapper.repository(:repository_one){MyModel.all}
范围只是DataMapper.repository,你可以通过 DataMapper.setup(:default,postgres:// localhost / my_primary_db)
等等设置 p>
Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection before loading source file with models. What ORM is better to use in sinatra application that uses different databases.
DataMapper is designed for multi-database use.
You can set up multiple repositories just by saying something like DataMapper.setup(:repository_one, "mysql://localhost/my_db_name")
.
DataMapper then tracks all the repositories that have been setup in a hash that you can reference and use for scoping:
DataMapper.repository(:repository_one){ MyModel.all }
(The default scope just being DataMapper.repository, which you can set up by saying DataMapper.setup(:default, "postgres://localhost/my_primary_db")
or the like)
这篇关于什么ORM在一个进程中使用多个db连接sinatra应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!