nagasurendra commited on
Commit
990ea8d
·
verified ·
1 Parent(s): 8c5f062

Update utils/database_handler.py

Browse files
Files changed (1) hide show
  1. utils/database_handler.py +1 -4
utils/database_handler.py CHANGED
@@ -1,7 +1,6 @@
1
  import pandas as pd
2
  import os
3
 
4
- # Path to Excel database
5
  CUSTOMERS_FILE = "database/customers.xlsx"
6
 
7
  # Ensure database exists
@@ -10,17 +9,15 @@ if not os.path.exists("database"):
10
  if not os.path.exists(CUSTOMERS_FILE):
11
  pd.DataFrame(columns=["Name", "Phone", "Email", "Password"]).to_excel(CUSTOMERS_FILE, index=False)
12
 
13
- # Check user credentials
14
  def check_credentials(email, password):
15
  df = pd.read_excel(CUSTOMERS_FILE)
16
  user = df[(df["Email"] == email) & (df["Password"] == password)]
17
  return not user.empty
18
 
19
- # Save new user
20
  def save_user(name, phone, email, password):
21
  df = pd.read_excel(CUSTOMERS_FILE)
22
  if email in df["Email"].values:
23
- return False # User already exists
24
  new_user = {"Name": name, "Phone": phone, "Email": email, "Password": password}
25
  df = pd.concat([df, pd.DataFrame([new_user])], ignore_index=True)
26
  df.to_excel(CUSTOMERS_FILE, index=False)
 
1
  import pandas as pd
2
  import os
3
 
 
4
  CUSTOMERS_FILE = "database/customers.xlsx"
5
 
6
  # Ensure database exists
 
9
  if not os.path.exists(CUSTOMERS_FILE):
10
  pd.DataFrame(columns=["Name", "Phone", "Email", "Password"]).to_excel(CUSTOMERS_FILE, index=False)
11
 
 
12
  def check_credentials(email, password):
13
  df = pd.read_excel(CUSTOMERS_FILE)
14
  user = df[(df["Email"] == email) & (df["Password"] == password)]
15
  return not user.empty
16
 
 
17
  def save_user(name, phone, email, password):
18
  df = pd.read_excel(CUSTOMERS_FILE)
19
  if email in df["Email"].values:
20
+ return False
21
  new_user = {"Name": name, "Phone": phone, "Email": email, "Password": password}
22
  df = pd.concat([df, pd.DataFrame([new_user])], ignore_index=True)
23
  df.to_excel(CUSTOMERS_FILE, index=False)