- How to Create a Table
The MySQL database is a relational database and stores its values in tables. After creating a database, now the next step is to create tables where we are going to insert our values as well as retrieve our data.
The syntax for creating a table includes:
CREATE TABLE student (id INT, name VARCHAR (255))
From the previous section, we have created a database Student now, we are going to create table marks.
CREATE TABLE marks (id INT, name VARCHAR (255))
- CRUD operations
Creating in CRUD operation simply means inserting data into your MySQL database.
To insert data into the MySQL table, we are going to use the method connection.commit () in order to get the changes. Now, let’s insert sample marks our marks table:
query = “insert into marks (Student_name, marks) values (%s, %s)”
value = [(“Annah”, “80”), (“Judy”, “70”), (“Ann”,”87”), (“Kimberly”, “54”)]
connection. Commit ()