PYTHON Tutorial
NoSQL (Not Only SQL) databases are a non-relational alternative to traditional relational databases. They were developed to handle large volumes of unstructured or semi-structured data that do not fit well into the tabular structure of relational databases.
Overview of NoSQL Databases
import pymongo
import redis
# Connect to a MongoDB document database
client = pymongo.MongoClient()
db = client.mydb
collection = db.mycollection
# Insert a document into the collection
document = {"name": "John", "age": 30}
collection.insert_one(document)
# Connect to a Redis key-value store
r = redis.Redis()
# Set a key-value pair
r.set("name", "John")
# Get the value associated with a key
value = r.get("name")
# Print the results
print(value)
This example demonstrates how to store and retrieve data in a MongoDB document database and a Redis key-value store, highlighting their differences compared to relational databases.