Hi all, does anyone maybe know whether one can output the name of the current used database during runtime (for example something like puts ''[i]currentDatabase[/i]''}) ? Regards, Y -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can grab a raw connection from an ActiveRecord based model object and ask it nicely:>> aro.connection.adapter_name=> "MySQL" On 11/4/06, Yu Co <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi all, > > does anyone maybe know whether one can output the name of the current > used database during runtime (for example something like puts > ''[i]currentDatabase[/i]''}) ? > > Regards, > Y > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Thanks, -Steve http://www.stevelongdo.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve been able to grab the current values for migrations using the following: ActiveRecord::Base.connection.instance_values[''config''][:database] ActiveRecord::Base.connection.instance_values[''config''][:host] ActiveRecord::Base.connection.instance_values[''config''][:username] ActiveRecord::Base.connection.instance_values[''config''][:password] Using those I can do a system call to run the command line mysql binary to import SQL data into newly created tables that are mostly used for static lookup tables that rarely change. When we get a new dump file I reload the sites manually and then check the new SQL dump file into SVN so that anyone doing a migrate will load the latest copy. # use current values from database.yml (already loaded into ActiveRecord) host = ActiveRecord::Base.connection.instance_values[''config''][:host] username = ActiveRecord::Base.connection.instance_values[''config''][:username] password = ActiveRecord::Base.connection.instance_values[''config''][:password] database = ActiveRecord::Base.connection.instance_values[''config''][:database] system "mysql -h#{host} -u#{username} -p#{password} #{database} " + "<db/zipcodes.import.sql" David Steve Longdo wrote:> You can grab a raw connection from an ActiveRecord based model object > and ask it nicely: > > >> aro.connection.adapter_name > => "MySQL" > > > > On 11/4/06, * Yu Co* <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > <mailto:rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> wrote: > > > Hi all, > > does anyone maybe know whether one can output the name of the current > used database during runtime (for example something like puts > ''[i]currentDatabase[/i]''}) ? > > Regards, > Y > > -- > Posted via http://www.ruby-forum.com/. > > > > > > > -- > Thanks, > -Steve > http://www.stevelongdo.com > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---