On Friday, April 16, 2010 12:42:48 PM UTC-7, Jeremy Evans wrote: > On Apr 16, 12:24 pm, Brian Takita <[email protected]> wrote: > > Hello, I'm using Friendly in my Rails application. Currently there is > > one db connection for ActiveRecord and one db connection for Sequel. > > > > I would like my Friendly objects to play nice with my other AR > > objects, specifically when dealing with transactions. > > > > Would it be possible to use the same connection object as ActiveRecord? > > Are there any bridges or apis out there? > > I think this is a bad idea, but it's probably doable: > > connection = > ActiveRecord::Base.connection.instance_variable_get(:@connection) > DB = Sequel.connect('...') > DB.meta_def(:connect){connection} > > This isn't thread safe of course, and it probably has numerous other > problems, but if you want it bad, you get it bad. > > Honestly, just use separate connections for Sequel and AR. You'll > have fewer problems that way. > > Jeremy >
Is this still the best way to do this? Has anyone else shared the database connection between Sequel and ActiveRecord? Having a connection open for both Sequel and ActiveRecord means double the number of database connections, which can get expensive with postgresql. ActiveRecord unfortunately doesn't play well with connection pooling (due to prepared statements), and I can't use connection pooling anyways (since I need to use listen/notify and setting of session variables). -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/viYDraOwOf0J. 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.
