import sqlite3
import os

DB = 'test.db'

class DbAccessor():
    def addNote(self, title, content):
        con = sqlite3.connect(DB)
        cur = con.cursor()

        note = (title, content)
        cur.execute('INSERT INTO Notes(Title, Content) VALUES(?,?)', note)

        con.commit()
        cur.close()

    def deleteNote(self, id):
        con = sqlite3.connect(DB)
        cur = con.cursor()

        cur.execute('DELETE FROM Notes WHERE Id = ' + str(id))

        con.commit()
        cur.close()

import sqlite3
import os

DB = 'test.db'

class DbAccessor():
    def __init__(self):
        self.con = sqlite3.connect(DB)
        self.cur = self.con.cursor()

    def addNote(self, title, content):
        note = (title, content)
        self.cur.execute('INSERT INTO Notes(Title, Content) VALUES(?,?)', note)

        self.con.commit()

    def deleteNote(self, id):
        self.cur.execute('DELETE FROM Notes WHERE Id = ' + str(id))

        self.con.commit()

use init method in DbAccessor to set up connection and cursor