0% found this document useful (0 votes)
8 views9 pages

Stream Processing Lab Manual

Lab manual for stream processing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Stream Processing Lab Manual

Lab manual for stream processing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

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:

Downloaded by Genshin Impact ([email protected])


lOMoARcPSD|50167572

Step 5:

Step 6:

Step 7:

Step 8:

Downloaded by Genshin Impact ([email protected])


lOMoARcPSD|50167572

Step 9:

Step 10:

Downloaded by Genshin Impact ([email protected])


lOMoARcPSD|50167572

1B. Relational Database Schema

Step 1:

Step 2:

Downloaded by Genshin Impact ([email protected])


lOMoARcPSD|50167572

EX NO: 2

REALTIME DATA ANALYSIS

Downloaded by Genshin Impact ([email protected])


lOMoARcPSD|50167572

3. INSTALL MONGODB

Step 1:

Step 2:

Step 3:

Downloaded by Genshin Impact ([email protected])


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>

Downloaded by Genshin Impact ([email protected])


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

Downloaded by Genshin Impact ([email protected])

You might also like