Error: DB not defined

Wondering if someone could highlight what I’m doing wrong here, seems to switch to the DB ok but then proceeds to state that it is ‘Not Defined’.


Hello @Kyle_24875,

Issue show collections

If there is none, then one possibility is that you didn’t load the sample dataset?

This is done in Atlas.


The general syntax for working with collections is:


in your case it would be

db.sample_training.find( ... )

So you forgot the leading db.


Hi @Kyle_24875,

Use db object rather than the name of your database in your queries.

When you run the use database_name command, the db object automatically starts pointing to the mentioned database.

1 Like

Thank you all for the extremely helpful advice!