title: How to establish 20 connections for concurrent connection tests in psycopg2
body: <p>I want to do some concurrent connection tests and hope to establish 50 concurrent connections to the database by psycopg2 adaptor. What should I do?</p>
  
  <p>Should I use the psycopg2.pool to establish concurrent connections or use Threading? </p>
  
  <pre><code>a = psycopg2.pool.SimpleConnectionPool(1,50,database='test')
  
  @contextmanager
  def getcursor():
      con = a.getconn()
      con.autocommit = True
      try:
          yield con.cursor()
      finally:
          a.putconn(con)
  
  
  for i in xrange(50):
      with getcursor() as cur:
      cur.execute("select * from test")
  </code></pre>
  
  <p>or should I directly create connection every time such as:</p>
  
  <pre><code>for i in xrange(50):
      con = psycopg2.connect(database='test',user='test', host='localhost', password='test')
      cur = con.cursor()
      cur.execute("select * from test")
      con.close()
  </code></pre>
  
  <p>Or should I create new threading every time? Thanks in advance</p>