15 "client = pymongo.MongoClient('mongodb://ogedei:27017/')"
23 "cell_type": "markdown",
26 "Connect to the `accidents` database"
33 "db = client.accidents\n",
34 "accidents = db.accidents"
45 "accidents.find().count()"
52 "output_type": "pyout",
62 "cell_type": "markdown",
65 "Drop any existing small accident database"
72 "client.drop_database('asmall')"
80 "cell_type": "markdown",
83 "Create a new database with a new collection.\n",
85 "Note that this is created lazily, so neither the database nor the collection will appear on the server until we've put some data in it."
92 "small_db = client.asmall\n",
93 "small_accidents = small_db.accidents"
101 "cell_type": "markdown",
104 "Copy the first 100 accidents across."
111 "for a in accidents.find(limit=100):\n",
112 " small_accidents.insert(a)\n",
113 "small_accidents.find().count()"
115 "language": "python",
120 "output_type": "pyout",
130 "cell_type": "markdown",
133 "Create the index for it."
140 "small_accidents.create_index('Accident_Index')"
142 "language": "python",
147 "output_type": "pyout",
160 "language": "python",