Python class to manage a table in SQLite
I exposed the database connection and database cur as instance variables. Is that a good practice?


Having a cursor defined as an instance variable is a common practice. The problem though here is that you don't have a way to close the cursor and the connection itself in case of an error. In situations like this, having "context manager" capabilities on your class would be quite handy:

def __enter__(self):
    return self

def __exit__(self, ext_type, exc_value, traceback):
    self.cursor.close()
    if isinstance(exc_value, Exception):
        self.connection.rollback()
    else:
        self.connection.commit()
    self.connection.close()


Then, the Database class could be used with with:

with Database() as db:
    db.create_table()