title: how to import and execute database connection in a script
body: <p>I am writing many scripts to run housekeeping tasks on our system. At the top of each script, I establish a connection to the database using ActiveRecord::Base.connection. I would like to keep this bit in it's own file, so If I move to another server, i can change it in only one place, but I have not found a way to do this.</p>
  
  <pre><code>ActiveRecord::Base::establish_connection({                                                                                                                                                                                              
      :adapter   =&gt; 'mysql',                                                                                                                                                                                                              
      :host      =&gt; 'ip.address',                                                                                                                                                                                                         
      :database  =&gt; 'test-db',                                                                                                                                                                                                            
      :username  =&gt; 'userName',                                                                                                                                                                                                           
      :password  =&gt; 'passWord'})   
  
  load_models
  keyWord = KeyWord.find(:all)
  </code></pre>
  
  <p>i need something like a function i can just call like</p>
  
  <pre><code>def set_connection
     connection code here
     return connection
  end
  </code></pre>
  
  <p>where, if run, my script will be connected to the database.</p>
  
  <p>i write my scripts using only the rubygems and activerecord gems. Not inside a rails app.</p>
  
  <p>thanks for any tips</p>