title: using sqlite3 in python with "WITH" keyword
body: <p>I was doing a tutorial and came across a way to handle connections with sqlite3,
  Then I studied about the WITH keyword and found out that it is an alternative to try,except,finally way of doing things</p>
  
  <p>It was said that in case of file-handling, 'WITH' automatically handles closing of files and I thought similar with the connection as said in zetcode tutorial:-</p>
  
  <blockquote>
    <p>"With the with keyword, the Python interpreter automatically releases
    the resources. It also provides error handling." <a href="http://zetcode.com/db/sqlitepythontutorial/" rel="noreferrer">http://zetcode.com/db/sqlitepythontutorial/</a></p>
  </blockquote>
  
  <p>so I thought it would be good to use this way of handling things, but I couldn't figure out why both (inner scope and outer scope) statements work? shouldn't the WITH release the connection?</p>
  
  <pre><code>import sqlite3
  
  con = sqlite3.connect('test.db')
  
  with con:    
      cur = con.cursor()    
  
      cur.execute('SELECT 1,SQLITE_VERSION()')
      data = cur.fetchone()   
      print data        
  
  cur.execute('SELECT 2,SQLITE_VERSION()')
  data = cur.fetchone()
  print data
  </code></pre>
  
  <p>which outputs</p>
  
  <pre><code>(1, u'3.6.21')
  (2, u'3.6.21')
  </code></pre>
  
  <p>I don't know what exactly the WITH is doing here(or does in general), so, if you will please elaborate on the use of WITH over TRY CATCH in this context.</p>
  
  <p>And should the connections be opened and closed on each query? (I am formulating queries inside a function which I call each time with an argument) Would it be a good practice?</p>