-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill_models.py
43 lines (34 loc) · 1.13 KB
/
fill_models.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
import csv
from models import db, Supplier, User, Company
db.drop_all()
db.create_all()
singapore = open('server/singapore.csv', 'r')
gibraltar = open('server/gibraltar.csv', 'r')
malta = open('server/malta.csv', 'r')
for f in csv.reader(singapore, delimiter=','):
name = f[0].strip()
emails = f[1].strip()
supplier1 = Supplier(name, emails, 'Singapore')
db.session.add(supplier1)
for f in csv.reader(gibraltar, delimiter=','):
name = f[0].strip()
emails = f[1].strip()
supplier2 = Supplier(name, emails, 'Gibraltar')
db.session.add(supplier2)
for f in csv.reader(malta, delimiter=','):
name = f[0].strip()
emails = f[1].strip()
supplier3 = Supplier(name, emails, 'Malta')
db.session.add(supplier3)
swire = Company('Swire Bulk')
oilfront = Company('OilFront')
db.session.add(swire)
db.session.add(oilfront)
db.session.commit()
buyer = User('buyer@oilfront.com', 'testbuyer', 'buyer', swire)
operator = User('operator@oilfront.com', 'testoperator', 'operator', swire)
admin = User('admin', '123', 'buyer', oilfront)
db.session.add(buyer)
db.session.add(operator)
db.session.add(admin)
db.session.commit()