Skip to content

mongoDB-2023/1-Introduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

1-Introduction

  1. Installing MongoDB in Linux
  2. Run MongoDB Community Edition
  3. Time to Get Started
  4. Shell vs Drivers
  5. Ref

1. Installing MongoDB in Linux

  • Import the public key used by the package management system
sudo apt-get install gnupg curl

To import the MongoDB public GPG key from https://pgp.mongodb.com/server-7.0.asc , run the following command:

curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
   --dearmor
  • Create a list file for MongoDB
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
  • Reload local package database
sudo apt-get update
  • Install the MongoDB packages
sudo apt-get install -y mongodb-org

2. Run MongoDB Community Edition

  • Start MongoDB
sudo systemctl start mongod
  • Verify that MongoDB has started successfully
sudo systemctl status mongod
  • You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
sudo systemctl enable mongod
  • Stop MongoDB
sudo systemctl stop mongod
  • Restart MongoDB
sudo systemctl restart mongod
  • Begin using MongoDB
mongosh
  • Exit MongoDb shell
exit

3. Time to Get Started

  • Show the DB Muestra las base de datos que tenemos.
show dbs
  • Insert one element
      1. use nombre_base_de_datos
      test> use basedegatos
      switched to db basedegatos
      
      1. insertOne({})
         db.basedegatos.insertOne({name: "Paco", age:2})
         {
           acknowledged: true,
           insertedId: ObjectId('655f3c51048dd06a35c960b7')
         }
    
  • Find elements find()
db.basedegatos.find()
[ { _id: ObjectId('655f3c51048dd06a35c960b7'), name: 'Paco', age: 2 } ]

4 . Shell vs Drivers

Los controladores (o drivers) de MongoDB para Python son bibliotecas que proporcionan una interfaz para que las aplicaciones escritas en Python se comuniquen con una base de datos MongoDB. Estos drivers facilitan la conexión, la consulta y la manipulación de datos en MongoDB desde Python.

https://www.mongodb.com/docs/drivers/pymongo/

  • pymongo: Es el controlador oficial de MongoDB para Python. Proporciona una interfaz de bajo nivel para interactuar con MongoDB y es muy utilizado en aplicaciones Python que se conectan a bases de datos MongoDB. Pymongo permite realizar operaciones como la inserción, actualización, eliminación y consulta de documentos en una base de datos MongoDB.

Ref

https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/#std-label-install-mdb-community-ubuntu

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors