Sobes.tech
Junior — Middle

Do you have experience working with MongoDB and PostgreSQL database management systems?

sobes.tech AI

Answer from AI

Yes, experience with MongoDB and PostgreSQL is common in development.

  • MongoDB is a document-oriented NoSQL database, well-suited for storing unstructured data and rapid prototyping. In Python, the pymongo library is usually used to work with MongoDB.

Example of connecting and inserting a document into MongoDB:

from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017/')
db = client['mydatabase']
collection = db['users']

user = {"name": "Ivan", "age": 30}
collection.insert_one(user)
  • PostgreSQL is a relational database supporting complex queries and transactions. In Python, psycopg2 or ORM like SQLAlchemy are often used.

Example of connecting and executing a query in PostgreSQL:

import psycopg2

conn = psycopg2.connect(dbname="mydb", user="user", password="pass", host="localhost")
cur = conn.cursor()
cur.execute("INSERT INTO users (name, age) VALUES (%s, %s)", ("Ivan", 30))
conn.commit()
cur.close()
conn.close()

Experience with both DBMS allows choosing the appropriate tool for specific tasks.

Do you have experience working with MongoDB and… - sobes.tech