'Returns a context manager that produces a database connection that
self-closes and calls rollback if an error occurs while using the
database connection'

@contextmanager
def get_db(self):

    conn = sqlite3.connect(self.db_path, check_same_thread=False, factory=SqliteConnection)
    conn.row_factory = sqlite3.Row
    conn.text_factory = str
    conn.execute('PRAGMA    synchronous    =    NORMAL')
    conn.execute('PRAGMA    count_changes    =    OFF')
    conn.execute('PRAGMA    temp_store    =    MEMORY')
    try:
        (yield conn)
    except sqlite3.DatabaseError as e:
        msg = (_LE('Error    executing    SQLite    call.    Got    error:    %s') % e)
        LOG.error(msg)
        conn.rollback()
    finally:
        conn.close()
