-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase_Mysql.py
More file actions
27 lines (22 loc) · 1.67 KB
/
Copy pathDatabase_Mysql.py
File metadata and controls
27 lines (22 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import mysql.connector as m
cn= m.connect(host="localhost",user="root",password="root",database="library")
cr=cn.cursor
cr.execute("create table users (username varchar(30), passw varchar(30))")
cr.execute("insert into users values('Anjali','abc123')")
cr.execute("insert into users values('Rahul','xyz123')")
cr.execute("insert into users values('Aarav','pqr123')")
cn.commit()
cr.execute("create table member(mid varchar(20) primary key,name varchar(50),email varchar(50), phone varchar(20))")
cr.execute("create table book(bookid varchar(20) primary key,title varchar(50), author varchar(50), publisher varchar(50), cost integer)")
cr.execute("create table issue(mid varchar(20), bookid varchar(20), dateofissue date)")
cr.execute("create table issuelog(mid varchar(20), bookid varchar(20), dateofissue date, dateofreturn date)")
cr.execute("insert into member values(002,'Anjali','Anjali002@gmail.com','+91 9999999992')")
cr.execute("insert into member values(003,'Rahul','Rahul003@gmail.com','+91 9999999993')")
cr.execute("insert into member values(001,'Aarav','Aarav001@gmail.com','+91 9999999991')")
cr.execute("insert into book values('GS_050','The Hotel Is Haunted','Geronimo Stilton','Scholastic',199)")
cr.execute("insert into book values('GS_015','The Mona Mouse Code','Geronimo Stilton','Scholastic',256)")
cr.execute("insert into book values('GS_052','The Mouse In Space','Geronimo Stilton','Scholastic',250)")
cr.execute("insert into book values('GS_050','Rumble In Tha Jungle','Geronimo Stilton','Scholastic',300)")
cr.execute("insert into issue values('002','GS_15','2023-10-12')")
cr.execute("insert into issue values('003','GS_52','2023-11-23')")
cn.commit()