Skip to content
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e155871
Review- Removing unused imports
Ihebdhouibi Sep 15, 2024
8e43594
Review- Adding windows timeout mechanism
Ihebdhouibi Sep 15, 2024
04bb477
Review- removing obselete code
Ihebdhouibi Sep 15, 2024
694330d
Review- Encapsulate global variable in a config class
Ihebdhouibi Sep 15, 2024
48a7ecf
Review- fixing typo in ScraperConfig class
Ihebdhouibi Sep 15, 2024
9d03605
Review- fixing typo in timeout cnstr
Ihebdhouibi Sep 15, 2024
31fdb56
Review- Fixing search_download call
Ihebdhouibi Sep 15, 2024
34e6cad
Review- missing parentheses
Ihebdhouibi Sep 15, 2024
173afd2
Review- fixing typo
Ihebdhouibi Sep 15, 2024
2c863d7
Review- search_download call fix
Ihebdhouibi Sep 15, 2024
d948deb
Review- Establishing DB connection using context manager
Ihebdhouibi Sep 15, 2024
704250c
Review- Removing commented lines
Ihebdhouibi Sep 15, 2024
b58e70d
Review- Apply code reusebility to store alerts functions
Ihebdhouibi Sep 15, 2024
f7e3782
Review- Apply code reusebility to retrieving alerts functions
Ihebdhouibi Sep 15, 2024
042b951
Review- Add exception handling
Ihebdhouibi Sep 15, 2024
6289aa9
Review- Add remove_camera function
Ihebdhouibi Sep 15, 2024
5a17c59
Review- Fixing typo
Ihebdhouibi Sep 15, 2024
d628218
Review- Add exception handling
Ihebdhouibi Sep 15, 2024
caebad0
Review- Fixing typo and naming in functions
Ihebdhouibi Sep 15, 2024
8517949
Review- Updating create_azure_container function
Ihebdhouibi Sep 15, 2024
4075fc5
Review- Remove commented lines
Ihebdhouibi Sep 15, 2024
f7893a4
Review- Updating upload_blob function
Ihebdhouibi Sep 15, 2024
244dcb2
Review- removing debbuging and unecessary lines
Ihebdhouibi Sep 15, 2024
aae9185
Review- Removing unecessary prints
Ihebdhouibi Sep 16, 2024
f1e5c12
Review- Removing commented code
Ihebdhouibi Sep 16, 2024
39616c3
Review- Documenting functions
Ihebdhouibi Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 12 additions & 33 deletions DataBase/dataBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def remove_camera(id):
pass

def store_alert_data(alert_time, video_link, alert_class, alert_type):

query = f"INSERT INTO {alert_type}_alerts (alert_time, video_link, class) VALUES (%s, %s, %s)"

with get_db_connection() as (cursor, conn):
Expand All @@ -56,45 +57,23 @@ def store_alert_data(alert_time, video_link, alert_class, alert_type):
except Exception as e:
print(f"Error inserting alert into {alert_type}_alerts: {e}")

Comment on lines 52 to 56

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always ensure handling exception in case of an error in the given SQL query

def retrieve_fire_alerts():

# Establishing Connection to DB
with get_db_connection() as (cursor, conn):
query = "select * from fire_alerts"
cursor.execute(query)
print("Fire alerts : \n ------------------------------------ \n")
fire_alerts = cursor.fetchall()
for row in fire_alerts:
print(f"ID : {row[0]} | alert time : {row[1]} | video link : {row[2]} | class : {row[3]}")


def retrieve_fall_alerts():

# Establishing Connection to DB
with get_db_connection() as (cursor, conn):
query = "select * from fall_alerts"
cursor.execute(query)
print("Fall alerts : \n ------------------------------------ \n")
fall_alerts = cursor.fetchall()
for row in fall_alerts:
print(f"ID : {row[0]} | alert time : {row[1]} | video link : {row[2]} | class : {row[3]}")

def retrieve_robbery_alerts():

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leveraging code_reusebility is important here as a centralized function with an additional parameter to decide which table to handle is a better approach

def retrieve_alerts(alert_type):

query=f"SELECT * FROM {alert_type}_alerts"

# Establishing Connection to DB
with get_db_connection() as (cursor, conn):
query = "select * from robbery_alerts"
cursor.execute(query)
print("Robbery alerts : \n ------------------------------------ \n")
robbery_alerts = cursor.fetchall()
for row in robbery_alerts:
print(f"ID : {row[0]} | alert time : {row[1]} | video link : {row[2]} | class : {row[3]}")
alerts = cursor.fetchall()
print(f"{alert_type.capitalize()} alerts: \n ----------------------------------------------- \n")

for row in alerts:
print(f"ID: {row[0]} | Alert Time: {row[1]} | Video Link; {row[2]} | Class: {row[3]}")

def retrieve_all_alerts():

retrieve_fire_alerts()
retrieve_fall_alerts()
retrieve_robbery_alerts()
retrieve_alerts("fire")
retrieve_alerts("fall")
retrieve_alerts("robbery")

def retrieve_users():

Expand Down