Thanks guys, that was really helpful. On Mar 5, 8:11 pm, Jeremy Evans <[email protected]> wrote: > On Mar 5, 5:28 pm, jv27243 <[email protected]> wrote: > > > > > I have models defined like so: > > > module X > > class A < Sequel::Model(:table_a) > > set_primary_key :id > > end > > class B < Sequel::Model(:table_b) > > set_primary_key :id > > end > > end > > > module Y > > class A < Sequel::Model(:table_a) > > set_primary_key :id > > end > > class C < Sequel::Model(:table_c) > > set_primary_key :id > > end > > end > > > Is there an easy way to create a DB connection mysql1 and assign it to > > all models in module X and a second connection mysql2 to all models in > > module Y? mysql1 and mysql2 are two separate mysql instances with > > unlike DB schemas. > > dusty gave pretty much the right idea, to apply it to your situation: > > module X > class A < Sequel::Model(mysql1[:table_a]) > set_primary_key :id > end > class B < Sequel::Model(mysql1[:table_b]) > set_primary_key :id > end > end > > module Y > class A < Sequel::Model(mysql2[:table_a]) > set_primary_key :id > end > class C < Sequel::Model(mysql2[:table_c]) > set_primary_key :id > end > end > > There isn't a way to say that all models in Y should use a specific > Database object, without setting the connection in every model. If > you don't set a connection for a model, it will use the first > instantiated Sequel::Database by default. > > Jeremy
-- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
