-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration.py
169 lines (161 loc) · 3.39 KB
/
migration.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# import MongoClient
from database import Database
db = Database()
collection = db.booksCollection()
books = [
{
"name":"Calculus With Fun",
"category": "Maths",
"rentPerDay": 20
},
{
"name":"Julius Caesar",
"category": "Play",
"rentPerDay": 10
},
{
"name":"Panch Tantra",
"category": "Stories",
"rentPerDay": 15
},
{
"name":"Jungle Book",
"category": "Stories",
"rentPerDay": 10
},
{
"name":"Ramayana",
"category": "Poetry",
"rentPerDay": 20
},
{
"name":"Godaan",
"category": "Novel",
"rentPerDay": 10
},
{
"name":"Prithviraj Raso",
"category": "Poetry",
"rentPerDay": 45
},
{
"name":"History of War",
"category": "History",
"rentPerDay": 20
},
{
"name":"Himalaya",
"category": "Geography",
"rentPerDay": 25
},
{
"name":"Modern Science",
"category": "Science",
"rentPerDay": 10
},
{
"name":"Atlas",
"category": "Geography",
"rentPerDay": 20
},
{
"name":"Lucant English Grammar",
"category": "English Grammar",
"rentPerDay": 10
},
{
"name":"Diary of a Wimpy Kid",
"category": "Novel",
"rentPerDay": 10
},
{
"name":"Law Of Motion",
"category": "Science",
"rentPerDay": 20
},
{
"name":"Human Body",
"category": "Science",
"rentPerDay": 10
},
{
"name":"Mahabarat",
"category": "Poetry",
"rentPerDay": 55
},
{
"name":"Akbar And Birbal",
"category": "Comics",
"rentPerDay": 20
},
{
"name":"Jatak Kathaye",
"category": "Story",
"rentPerDay": 40
}, {
"book_name":"",
"person_name":"Vijay",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Raj",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Suresh",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Mukesh",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Ram",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Shyam",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Mohan",
"issued_date":"",
"returned_date":"",
},
{
"book_name":"",
"person_name":"Gudia",
"issued_date":"15/5/2022",
"returned_date":"",
},
{
"name":"Indian Recepies",
"category": "Food",
"rentPerDay": 10
},
{
"name":"Science and Ghost",
"category": "Science",
"rentPerDay": 10
}
]
for book in books:
rec_id = collection.insert_one(book)
print("Data inserted with record name ", book['name'])
transactions_collection = db.transactionsCollection()
transactions = []
for transaction in transactions:
rec_id = transactions_collection.insert_one(transaction)
print("Data inserted with record person_name ", transaction['person_name'])