0% found this document useful (0 votes)
23 views

Python MySQL Connectivity

1. The document describes creating a database and table using Python. 2. It connects to a MySQL database called 'localhost' as the root user without a password. 3. It then creates a database called 'SCHOOL' and a table within it called 'STUDENT' with various fields like Roll, Name, Class, etc. 4. The changes are committed to permanently save them to the database.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Python MySQL Connectivity

1. The document describes creating a database and table using Python. 2. It connects to a MySQL database called 'localhost' as the root user without a password. 3. It then creates a database called 'SCHOOL' and a table within it called 'STUDENT' with various fields like Roll, Name, Class, etc. 4. The changes are committed to permanently save them to the database.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

① WApin pythontcreatedatabasThencreate

am-vanchar l
STUDENT
having fields-Roll- it

connector
Step-1 import
:

mysql
as

myconn
db connect chost="local host's =root", panword
Step 2 :

mycom- X
=
user
IS
,
=root"
Database/connec-on object)
I

Step 3 :
db-cursor ()
mycursor
=


cursor
object
that executes
cobject sal code and
any
takes
output if any
Step 1 : 21 : CREATE DATABASE SCHOOL

Step 5 :
execute (as)
my
cursor
·

G2= "USE SCHOOL"

cursor. execute (q2)


my
93=" CREATE TABLE STUDENT

C Roll int PRIMARY KEY ,


Name Varchar (70),
clas int,
see char (1)
,

mark int,
Stream Varchar (1) "

execute (93)
my
cursor
.

S-s db commit ()
->
.

S 7 db
- close()
permanently
-

save whatever
activity
done
orchange
aubase .

You might also like