import pymysql.cursors # Connect to students #Configuration Values endpoint = 'localhost' username = 'honglam' password = 'project' database_name = 'student' #Connection connection = pymysql.connect(host=endpoint, user=username, passwd=password, db=database_name, cursorclass=pymysql.cursors.DictCursor) with connection: with connection.cursor() as cursor: # Create a new record sql = "INSERT INTO `display_student` (`student_id`, `student_name`, `title`, `option1`, `option2`, `option3`, `option4`, `diagnostic`, `ans`, `date_posted`, `attempted`, `correctness`, `stage`, `band`, `bundle`, `bundle_order`, `difficulty_of_question`, `hint1`, `hint2`, `hint3`, `hint4`, `mastery_level`, `node`, `question`, `student_mastery`, `topic`, `time_sent`, `api_call_time`, `content`, `left_hand_side`, `step_1`, `step_10`, `step_2`, `step_3`, `step_4`, `step_5`, `step_6`, `step_7`, `step_8`, `step_9`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" cursor.execute(sql, ('4', 'hanaf', '

Water is poured at a constant rate of \\(10~\\text{cm}^3\\) into an inverted right cone with semi-vertical angle \\(45^{\\circ}\\) as shown in the diagram. After \\(t\\) seconds, the depth of water in the cone is \\(h~\\text{cm}\\).

\r\n\r\n

\"be\"

\r\n\r\n

[It is given that volume of cone = \\(\\frac{1}{3}\\pi r^2h\\)]

', '', '', '', '', '', '', '2021-07-07 08:02:27.838442', 'N', '0', '0', '2', '3', '1', '1', '', '', '', '', '1', '6', '', '0', '1', '2021-07-07 08:02:27.838575', 'Wed, 07 Jul 2021 08:02:22 GMT', '', '', '', '', '', '', '', '', '', '', '', '')) # connection is not autocommit by default. So you must commit to save # your changes. connection.commit() with connection.cursor() as cursor: # Read a single record sql = "SELECT `id`, `student_id`, `student_name`, `title` FROM `display_student` WHERE `student_name`=%s" cursor.execute(sql, ('hanaf',)) result = cursor.fetchone() print(result)