Practical 10
Practical 10
OUTPUT:
10-b) Design a database application to search the specified record from the
database.
CODE:
import mysql.connector
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='12345678',
database='academy')
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM student")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
OUTPUT:
10-c) Design a database application to that allows the user to add, delete and
modify the records.
i) ADDING A RECORD TO EXISTING RECORDS:
CODE:
import mysql.connector
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='12345678',
database='academy')
mycursor = mydb.cursor()
a ="INSERT INTO student (student_id, student_name) VALUES (%s, %s)"
b = [("7", "Ramesh")]
mycursor.executemany(a, b)
mydb.commit()
print(mycursor.rowcount, "was inserted.")
OUTPUT:
OUTPUT:
OUTPUT: