title: Django - permanent connection to external database
body: <p>While iteration adding records to a local database I need to connect to an external database to import the data. It takes quite a long time. I get the impression that the reason is creating a new connection during each loop iteration. Does it possible to set the connection to an external database permanently?</p>
  
  <pre><code>def setup_cursor():
      try:
          cursor = connections['legacy'].cursor()
          return cursor
      except ConnectionDoesNotExist:
          print "Legacy database is not configured"
          return None
  
  
  def make_query(sql):
      cursor = setup_cursor()
      if cursor is None:
          return
      cursor.execute(sql)
      rows = cursor.fetchall()
      if rows is None:
          return
      return rows
  
  def get_external_data(var):
      sql = "...."
      result = make_query(sql.format(var))
      return result
  
  # adding records to local db
  for x in y:
      add_row = SomeModel (field1=xxx, field2=get_external_data(var))
      add_row.save()
  </code></pre>