-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlLoader.py
95 lines (82 loc) · 2.69 KB
/
sqlLoader.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import mysql.connector
mydb = mysql.connector.connect(host = 'localhost', user = 'root', passwd = 'root', db = 'dex')
mycursor = mydb.cursor()
mycursor.execute('create table items(name varchar(300), type varchar(20), price int, img varchar(300))')
mycursor.execute('create table cart(name varchar(100), price int)')
mycursor.execute('create table lastpurch(name varchar(100) primary key, price int, time varchar(50), date date)')
mydb.commit()
#---------------------------WOMEN------------------
f = open('data\WomenBottomwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","women_bottom",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\WomenTopwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","women_top",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\WomenFootwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","women_foot",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
#---------------------------MEN------------------
f = open('data\MenBottomwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","men_bottom",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\MenTopwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","men_top",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\MenFootwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","men_foot",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
#--------------------------------KIDS-----------------------
f = open('data\KidsBottomwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","kids_bottom",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\KidsTopwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","kids_top",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()
f = open('data\KidsFootwear.txt', 'r',)
lines = f.readlines()
for i in lines:
j = i.split()
print(j)
mycursor.execute('insert into items values("' + j[2] + '","kids_foot",' + j[0] + ',"' + j[1]+'");')
mydb.commit()
f.close()