title: Building a class to use `with` to establish exclusive sql connections
body: <p>I am working on a simple convenience class to use with the <code>with</code> operator so that I can establish exclusive access to a sqlite3 database for a extended writing session in a concurrent system.</p>
  
  <p>Here is the class:</p>
  
  <pre><code>import sqlite3 as sql
  
  class ExclusiveSqlConnection(object):
      """meant to be used with a with statement to ensure proper closure"""
      def __enter__(self, path):
          self.con = sql.connect(path, isolation_level = "EXCLUSIVE")
          self.con.execute("BEGIN EXCLUSIVE")
          self.cur = self.con.cursor()
          return self
  
      def __exit__(self):
          self.con.commit()
          self.con.close()
  </code></pre>
  
  <p>However, when I run this I get the error:</p>
  
  <pre><code>with sql_lib.ExclusiveSqlConnection(self.output) as c:
  TypeError: object.__new__() takes no parameters
  </code></pre>