Inserting the first Document in the MongoDB Collection using Robo 3T Provide the desired collection name in the “Collection Name:” field, this tutorial will use “testCollection” then click Create to create the first collection in this database.Īs a result the “Collections (0)” will update to “Collections(1)” and “testCollections” appears within the Collection folder. Once the database is created, click the arrow on the left-side of the testDatabase then right click on the Collections(0) folder (0 means no collection) and select the Create Collection. The testDatabase is now listed in the list of databases as shown in the following:Ĭreating the first Collection in the MongoDB Database using Robo 3T The “Create Database” window will appear asking the user to enter the desired database name in the “Database Name” field.įor the purpose of this demonstration the name of the database will be testDatabase, then click on the Create button to create the database. To create a new MongoDB database, right-click on the New Connection and select Create Database in the pop-up menu. Once the connection is successful, MongoDB will display all the available databases within the MongoDB deployment. To start the process, open the Robo 3T application and connect to a configured MongoDB Deployment by clicking Connect button at the lower right hand corner of the MongoDB Connections window.Ĭreating the MongoDB Database in Robo 3T GUI ![]() How to install and setup a MongoDB Server on macOS How to Install and Setup MongoDB on Windows NOTE: If MongoDB is not properly installed you can refer to the following articles on how to install MongoDB in each of the different OSs. If you have it installed you can run it in the background with the mongod commmand.Įnsure that Robo3T is properly installed before hand. PrerequisitesĮnsure that MongoDB is properly installed and running in the background. ![]() Robo 3T, formerly known as “Robomongo” is one of the leading MongoDB GUI ( Graphical User Interface ) tools out there that provides an easy way to interact with MongDB databases instead of the command line or Mongo Shell. This reference is a key in app.config whose value is a dict containing the connection parameters: app.This article will discuss and show the simple steps of configuring a MongoDB database within Robo 3T GUI. But before the initialization is done, we'll need a reference to our MongoDB instance. Which we'll use to initialize a MongoEngine object. Then, we can create the Flask app object: We will start by importing Flask and Flask-MongoEngine into our app: from flask import Flaskįrom flask_mongoengine import MongoEngine Now that we have installed Flask and Flask-MongoEngine, we need to connect our Flask app with a MongoDB instance. Instructions to get and install MongoDB can be found in the official documentation.Īnd with that done, we'll also want to install the Flask-MongoEngine library: $ pip install flask-mongoengine Connecting to a MongoDB Database Instance Next, we'll need access to a MongoDB instance, MongoDB provides a cloud instance - the MongoDB Atlas - that we can use for free, however, we will be using a locally installed instance. ![]() To get started, let's install Flask if you don't have it already: $ pip install flask To explore some of the features of MongoEngine, we'll be creating a simple movie API that allows us to perform CRUD operations on Movie instances. MongoEngine is an ODM (Object Document Mapper) that maps Python classes (models) to MongoDB documents, making it easy to create and manipulate documents programatically straight from our code. In this guide, we'll be exploring how to integrate MongoDB with Flask using a popular library - MongoEngine, and more specifically, its wrapper - Flask-MongoEngine.Īlternatively, you can integrate MongoDB with Flask-PyMongo. In this guide, we shall be taking a look at how to integrate one of the most popular NoSQL databases - MongoDB - with the Flask micro-framework. ![]() There are various databases to choose from, depending on your preference. Building a web app almost always means dealing with data from a database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |