Python MongoDBLesson 125Free preview
MongoDB Create DB
This lesson is part of Python · All levels
Summary
This lesson explains how a database works in MongoDB that is different from MySQL, which is a database that is created automatically when the first data is stored. You just access the client and work with the collection inside. The database list can be checked with client.list_database_names().
Key points
- Databases and collections in MongoDB are customized, not required to use the special CREATE command.
- A new database will appear on the list once it contains at least one document.
- Access the database with the client["store"] or client.toko, then close with client.close().
- Built-in admin, config, and local databases should be avoided for application data storage.
- MongoDB is schemaless: documents in a collection may have different fields.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.