MongoDB for Developers with Python Transcripts
Chapter: MongoDB's shell and native query syntax
Lecture: Concept: Connecting to MongoDB with the shell
0:01 So let's review the main concepts around using the shell.
0:03 Remember you just typed mongo enter
0:05 and it will connect your local default, everything default port,
0:08 default local host, no account etc,
0:11 and once we're connected, we'll be in here,
0:15 and it'll say connected to the server,
0:17 what version of the shell, what version of the server,
0:19 3.4.4 is the latest at the time of this recording,
0:22 but maybe not at the time you are watching it,
0:24 like all things that are server's, newer is better.
0:26 Ok, so first thing that we might want to do is say what databases are here,
0:29 and we do that with the show dbs command, we hit enter,
0:32 and it shows you the various databases that are listed.
0:35 Then next we want to activate one,
0:37 so that we can issue commands to it through the db.collection
0:40 or other high level operations,
0:42 so we'd say in this case let's work with talk_python, so we'd use talk_python.
0:46 And it'll say great, we switch to database talk_python,
0:50 and in you're wondering you can always trying as you saw me do
0:53 db enter and it will say talk_python, cool, and then,
0:55 we could say well what collections exist in talk_python?
0:57 This is actually pretty straightforward,
0:59 the document design I think is pretty interesting
1:01 but there's not many collections,
1:04 so we have episodes, guest, reviews and then while developing it,
1:08 I turned on profiling to see where it was slow and where it was fast,
1:11 where I need indexes, we'll talk more about that near the end of the course.
1:14 So we have these four collections, and now if we want to find an episode
1:18 we'd say db.episodes.find and give it some search,
1:23 or sort, or something to that effect.
1:25 So this is how we get started and connect with the shell.