lOMoARcPSD|50167572
Stream Processing Lab Manual
Stream Processing (Ramco Institute of Technology)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by Genshin Impact (
[email protected])
lOMoARcPSD|50167572
1A. POSTGRESQL Installation and Configuration
Step 1:
Step 2:
Step 3:
Step 4:
lOMoARcPSD|50167572
Step 5:
Step 6:
Step 7:
Step 8:
lOMoARcPSD|50167572
Step 9:
Step 10:
lOMoARcPSD|50167572
1B. Relational Database Schema
Step 1:
Step 2:
lOMoARcPSD|50167572
EX NO: 2
REALTIME DATA ANALYSIS
lOMoARcPSD|50167572
3. INSTALL MONGODB
Step 1:
Step 2:
Step 3:
lOMoARcPSD|50167572
4. MONGODB WEB APPLICATION
App.py:
from flask import Flask, render_template, request
from flask_pymongo import PyMongo
app = Flask(__name__)
# Configure MongoDB
app.config["MONGO_URI"] = "mongodb://localhost:27017/myDatabase"
mongo = PyMongo(app)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/submit', methods=['POST'])
def submit():
fname = request.form['fname']
lname = request.form['lname']
emp_id = request.form['emp_id'] # Ensure this is unique or use MongoDB's _id
salary = request.form['salary']
emp_collection = mongo.db.table # 'table' is the collection name
emp_collection.insert_one({'fname': fname, 'lname': lname, 'emp_id': emp_id, 'salary
return render_template('success.html', data=fname)
if __name__ == '__main__':
app.run(debug=True)
Index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/static/style.css">
</head>
<body>
<div>
<form action="/submit" method="POST">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<label for="emp_id">Employee ID:</label><br>
<input type="number" id="emp_id" name="emp_id"><br><br>
<label for="salary">Salary:</label><br>
lOMoARcPSD|50167572
5. APPLY QUERY DESIGN TO SYSTEM USING MONGOD
Collections:
Insert:
db.accounts.insertOne({
"_id": ObjectId(), // Generate a new ObjectId for _id
"accountID": 1,
"accountName": "Checking Account",
"userID": 1,
"accountType": "Checking",
"balance": 1000,
"interestRate": "0.25%",
"openingDate": ISODate("2024-03-14T00:00:00.000Z")
});
Update:
db.transactions.updateOne(
{ "_id": ObjectId("65f3e703fd04b76977bf036c") }, // Filter criteria to find the
update
{
$set: { // Specify the fields to update
"date": ISODate("2024-03-14T00:00:00.000Z"), // Update the date field
"amount": 150, // Update the amount field