15 "client = pymongo.MongoClient('mongodb://ogedei:27017/')"
26 "db = client.accidents\n",
27 "accidents = db.accidents\n",
28 "vehicles = db.vehicles\n",
29 "casualties = db.casualties"
40 "accidents.find().count()"
47 "output_type": "pyout",
60 "casualties.find().count()"
67 "output_type": "pyout",
80 "[accidents.find_one({'Accident_Index':v['Acc_Index']}, ['Accident_Index', 'Date']) \n",
81 " for v in vehicles.find(fields=['Acc_Index'], limit=10)]"
88 "output_type": "pyout",
101 "# Find all the vehicles that don't have an accident\n",
102 "for v in vehicles.find(fields=['Acc_Index']):\n",
103 " if not accidents.find_one({'Accident_Index': v['Acc_Index']}):\n",
106 "language": "python",
115 "for v in vehicles.find():\n",
116 " accidents.update({'Accident_Index': v['Acc_Index']}, {'$push' : {\"Involved_Vehicles\" : v}})"
118 "language": "python",
127 "for v in vehicles.find():\n",
128 " accidents.update({'Accident_Index': v['Acc_Index']}, {'$push' : {\"Vehicles\" : v}})"
130 "language": "python",
139 "for c in casualties.find():\n",
140 " accidents.update({'Accident_Index': c['Acc_Index']}, {'$push' : {\"Casualties\" : c}})"
142 "language": "python",
151 "accidents.update({\"$exists\": \"Involved_Vehicles\"}, {\"$unset\": {\"Involved_Vehicles\":1}})"
153 "language": "python",
158 "output_type": "pyout",
161 "{'connectionId': 20, 'err': None, 'n': 0, 'ok': 1.0, 'updatedExisting': False}"
171 "accidents.find({\"Involved_Vehicles\" : {\"$exists\" : 1}}).count()"
173 "language": "python",
178 "output_type": "pyout",
191 "accidents.update({\"Involved_Vehicles\" : {\"$exists\" : 1}}, {\"$unset\": {\"Involved_Vehicles\":1}}, multi=True)"
193 "language": "python",
198 "output_type": "pyout",
201 "{'connectionId': 20, 'err': None, 'n': 57, 'ok': 1.0, 'updatedExisting': True}"
211 "language": "python",