def METHOD_NAME(self, state, project):
    fields = [
        "test_state",
        "target_dbname",
        "target_host",
        "target_name",
        "target_schema",
        "target_threads",
        "target_type",
        "target_user",
        "target_pass",
        "run_started_at",
        "invocation_id",
        "thread_id",
    ]
    field_list = ", ".join(['"{}"'.format(f) for f in fields])
    query = f"select {field_list} from {project.test_schema}.on_run_hook where test_state = '{state}'"
    vals = project.run_sql(query, fetch="all")
    assert len(vals) != 0, "nothing inserted into on_run_hook table"
    assert len(vals) == 1, "too many rows in hooks table"
    ctx = dict([(k, v) for (k, v) in zip(fields, vals[0])])
    return ctx