diff_msg = Differ().compare(retrieved_schema.splitlines(),
stored_schema.splitlines())
raise HandledException(msg_err + '\n'.join(diff_msg))
+
+
+class DatabaseConnection:
+ """A single connection to the database."""
+
+ def __init__(self, db_file: DatabaseFile):
+ self.file = db_file
+ self.conn = sql_connect(self.file.path)
+
+ def commit(self):
+ """Commit SQL transaction."""
+ self.conn.commit()
+
+ def exec(self, code: str, inputs: tuple = ()):
+ """Add commands to SQL transaction."""
+ return self.conn.execute(code, inputs)
+
+ def close(self):
+ """Close DB connection."""
+ self.conn.close()