MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / main

Function main

code/fake_data/mongo_fake_PO.py:62–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60 return order, total_price
61
62def main():
63 T_start = time.time()
64 n_orders = 10_000
65 price = { 'bike' : 80.00, 'golf club' : 120.00,
66 'ball' : 4.50, 'glove' : 25.00, 'hat' : 8.25}
67 local = True
68 if local:
69 client = MongoClient('localhost:27017')
70 else:
71 uri = "mongodb://%s:%s@%s/purchase_orders" % (
72 quote_plus('al'),
73 quote_plus('SuperSecret'),
74 quote_plus('413.198.231.158:27027'))
75 client = MongoClient(uri)
76 db = client.purchase_orders
77 all_PO = []
78 for i in range(n_orders):
79 PO = start_new_order()
80 PO['order'], PO['total_price'] = order_items(price)
81 all_PO.append( PO )
82 db.purchase_orders.insert_many( all_PO )
83 print(f'added {n_orders} orders in {time.time()-T_start:.3f} s')
84
85if __name__ == "__main__": main()

Callers 1

mongo_fake_PO.pyFile · 0.70

Calls 2

start_new_orderFunction · 0.85
order_itemsFunction · 0.85

Tested by

no test coverage detected