'Use with the "with" statement; returns a database connection.'

@contextmanager
def get(self):

    if (not self.conn):
        if ((self.db_file != ':memory:') and os.path.exists(self.db_file)):
            try:
                self.conn = get_db_connection(self.db_file, self.timeout)
            except (sqlite3.DatabaseError, DatabaseConnectionError):
                self.possibly_quarantine(*sys.exc_info())
        else:
            raise DatabaseConnectionError(self.db_file, "DB    doesn't    exist")
    conn = self.conn
    self.conn = None
    try:
        (yield conn)
        conn.rollback()
        self.conn = conn
    except sqlite3.DatabaseError:
        try:
            conn.close()
        except Exception:
            pass
        self.possibly_quarantine(*sys.exc_info())
    except (Exception, Timeout):
        conn.close()
        raise
