PW Akshay

Generation

generate functionFri, 02 Dec 2022

Create a student table and insert data. Implement the following SQL commands on the student table

# Create student table cur.execute("CREATE TABLE IF NOT EXISTS student (name TEXT, studentNumber INTEGER)") # Insert data cur.execute("INSERT INTO student VALUES('Bob', 123456)") cur.execute("INSERT INTO student VALUES('Alice', 234567)") cur.execute("INSERT INTO student VALUES('John', 345678)") # Commit conn.commit() # Query cur.execute("SELECT * FROM student") print(cur.fetchall()) # Delete cur.execute("DELETE FROM student WHERE name='Bob'") # Update cur.execute("UPDATE student SET studentNumber=987654 WHERE name='John'") # Commit conn.commit() # Query cur.execute("SELECT * FROM student") print(cur.fetchall())

Questions about programming?Chat with your personal AI assistant