MongoDB for Developers with Python Transcripts
Chapter: High-performance MongoDB
Lecture: Creating the big DB

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Here we are in the github repository for this course and notice we have this data section and in here I have this thing called dealership db 250 K
0:10 that is this data that I just talked about, with the 250 thousand cars, 100 thousand owners, that sort of thing.
0:17 So I'm going to put that over here on the desktop and unzip it
0:22 and if we look in here, you'll see that there's a cars collection and an owners collection,
0:30 and I don't believe we've spoken about how to get this data into MongoDB, so let's go over here and I'll use RoboMongo,
0:38 notice we have these two dealership things that I have been playing with
0:43 and I want to create one called like test dealership or something to that effect. We're going to restore this— how do we do that,
0:52 we'll go like this, we'll say mongorestore and this is the way that we get this exported data imported into MongoDB,
1:01 now, the first thing you have to ask yourself is this additive to the database, if it exists do you want to also insert this,
1:08 or do you want to have this be the database and replace anything it exists, we want this one to replace existing data
1:15 so I'll say --drop and then I need to tell it what database so I'll say db and I could say what you should say is this dealership,
1:24 but just because I don't want to wipe away what I currently have, I'll say dealership example, but the code that you're going to run
1:32 expects the name of the database to be just a dealership; and then I need to give it the folder that it's going to work from,
1:38 so I am just going to give it this folder like so, all right. So mongorestore, drop to replace the data -- db to name it, and then the location,
1:47 we hit go, and it's going to go cranking away on this and you can see it's inserting, inserting and done,
1:54 that was really fast for like close to 1.5 million records. All right, so let's go over here and refresh
2:01 and here's our example and we can see that we have our collection, here's our cars and we could just ask how many cars are there.
2:08 Notice, there is that many, and if we change this to owners, remember you can also write it like this, owners like this,
2:17 Now notice, I think the restore data we got here, you want to drop this index right here, I have it only have the id indexes, ok
2:27 so that's this example I just restored, we're going to work with something you can imagine is exactly the same.
2:34 So we're going to work with this dealership code but the way it got there, I'll show you the app I used to originally create it,
2:40 and then I just restored it using mongorestore just as I showed you up here.
2:44 So the way to generate the data that goes into mongorestore, you say mongo dump.


Talk Python's Mastodon Michael Kennedy's Mastodon