0% found this document useful (0 votes)
18 views3 pages

Import Mysql

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)
18 views3 pages

Import Mysql

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/ 3

import mysql.

connector as m

b=m.connect(host=’localhost’,user=’root’,passwd=’1234’)

c=b.cursor()

c.execute(‘show databases’)

for i in c:

print(i)

~c.execute(‘use scl’)

~c.execute(‘create database scl’)

c.execute(‘use scl’)

c.execute(‘create table sttt (rno int(4) primary key,name varchar(30),clas char(4), marks decimal(4,2))’)

c.execute(‘show tables’)

for I in c:

print(i)

#if the value is to be taken out from user

while True:

r=int(input(‘enter roll’))

n=input(‘name’)

cl=input(‘class’)

mq=float(input(‘marks’))

ss=input(‘u want to continue y/n’)

if ss.lower()==’n’:

break

d={‘1’:r,’2’:n,’3’:cl,’4’:mq}

~z=’insert into sttt values(d[‘1’],d[‘2’],d[‘3’],d[‘4’])’

c.execute(z)
c.commit()

~q=’insert into sttt values({},’{}’,’{}’,{}).format(d[‘1’],d[‘2’],d[‘3’],d[‘4’])’

c.execute(q)

c.commit()

#If the value is given

~w=’insert into sttt values(1233,’prapti’,’xiib’,100)’

c.execute(w)

c.commit()

~y=’insert into sttt values(%S,%S,%S,%S)’

L=[(1234,’saaala’,’xiib’,90),(1231,’saaaalllaa’,’xiib’,92)]

c.execute(y,L)

c.commit()

per=float(input(‘percentage’))

cm=input(‘classss’)

f=’select * from sttt where marks>{}.format(per) and cla=’{}’.format(cm)’

c.execute(f)

L=c.fetchmany()

For I in L:

print(i)

c.execute(‘ALTER TABLE STT ADD HOUSE CHAR(4)’)

mb=c.rowcount()

print(‘total no of row’,mb)

c.close()

b.close()

You might also like