0% found this document useful (0 votes)
7 views1 page

ML 1

The document provides a practical example of connecting Python to a MySQL database using the mysql.connector library. It includes code that connects to a local MySQL database, retrieves data from a 'student' table, and prints the results. The output section is left blank, indicating that the results of the execution are not included.

Uploaded by

tanyatomar766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

ML 1

The document provides a practical example of connecting Python to a MySQL database using the mysql.connector library. It includes code that connects to a local MySQL database, retrieves data from a 'student' table, and prints the results. The output section is left blank, indicating that the results of the execution are not included.

Uploaded by

tanyatomar766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

PRACTICAL-1

QUES: Python connectivity with mysql


CODE:
import mysql.connector as a
mycon=a.connect(host="localhost", user="root", passwd="",database="pqr")
cursor=mycon.cursor()
cursor.execute("select*from student")
data=cursor.fetchall()
for i in data:
print(i)

OUTPUT:

You might also like