()
| 60 | return order, total_price |
| 61 | |
| 62 | def 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 | |
| 85 | if __name__ == "__main__": main() |
no test coverage detected