Noey commited on
Commit
7297915
1 Parent(s): ab2074f

Update README.md

Browse files

# Create cursor
cursor = conn.cursor()

# User input book information
class books:
def add(self):
name = input("Enter the name of the book : ")
auth = input("Enter the name of the author : ")
price = int(input("Enter the Price : "))
qty = int(input("Enter the Qty Recived : "))
query = f"INSERT INTO books(name, auth, price, qty) VALUES('{name}', '{auth}', {price}, {qty})"
cursor.execute(query)
conn.commit()
print("Book Record Inserted Successfully")

#User input to update the price of the book
def update_price(self):
id = int(input("Enter the id of the book for update in price : "))
query = f"SELECT name, price FROM books WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
name, price = result
print(f"The Name of the book is : {name}")
print(f"The current price of the book is : {price}")
choice = input("Do you Want to Update the Price [y/n] : ")
if choice.lower() == 'y':
new_price = int(input("Enter the new price : "))
query = f"UPDATE books SET price = {new_price} WHERE id = {id}"
cursor.execute(query)
conn.commit()
print("Book Price Updated Successfully")
else:
print("No changes Made!!")
else:
print("No Book found!!!")

#Checking how many books are left in the inventory
def search(self):
id = int(input("Enter book id for details : "))
query = f"SELECT * FROM books WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
id, name, auth, price, qty = result
print(f"The Details of Book Id {id}")
print(f"The Name of the book is : {name}")
print(f"THE Author of {name} is {auth}")
print(f"The Price of the book is : {price}")
print(f"The inventory count is {qty}")
else:
print("No record Found")

#Check if orders have been updated
def update(self):
query = "SELECT book_id, qty FROM purchases WHERE recieves = 'T' AND inv IS NULL"
cursor.execute(query)
results = cursor.fetchall()
if results:
for result in results:
book_id, qty = result
query = f"UPDATE books SET qty = {qty} WHERE id = {book_id}"
cursor.execute(query)
conn.commit()
print("The orders recieved have been updated.")
else:
print("No orders recieved.")

#Choosing all of the book information
def display(self):
query = "SELECT * FROM books"
cursor.execute(query)
results = cursor.fetchall()
if results:
for result in results:
id, name, auth, price, qty = result
print(f"Name for book {id}: {name}")
print(f"Name of Author: {auth}")
print(f"Price: {price}")
print(f"Quantity: {qty}")
print()
else:
print("No books found.")

#Input supplier information
class suppliers:
def add_sup(self):
name = input("Enter the Supplier Name : ")
phn = int(input("Enter Phone no. : "))
addr_line1 = input("Enter the address (line 1) : ")
addr_line2 = input("Enter the address (line 2) : ")
addr_city = input("Enter the city : ")
addr_state = input("Enter the state : ")
query = f"INSERT INTO suppliers(name, phone_no, addr1, addr2, addr_city, addr_stat) VALUES('{name}', {phn}, '{addr_line1}', '{addr_line2}', '{addr_city}', '{addr_state}')"
cursor.execute(query)
conn.commit()
print("Supplier Record Inserted Successfully")

#Remove supplier
def remove_supplier(self):
id = int(input("Enter the supplier id to remove the Supplier : "))
query = f"DELETE FROM suppliers WHERE id = {id}"
cursor.execute(query)
conn.commit()
print("Supplier Removed.")

#Look up supplier ID
def search_id(self):
id = int(input("Enter the supplier id to find the Supplier details : "))
query = f"SELECT * FROM suppliers WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
id, name, phn, addr_line1, addr_line2, addr_city, addr_state = result
print(f"Details of Supplier Id: {id}")
print(f"Name: {name}")
print(f"Phone no.: {phn}")
print(f"Address Line 1: {addr_line1}")
print(f"Address Line 2: {addr_line2}")
print(f"City: {addr_city}")
print(f"State: {addr_state}")
else:
print("No Supplier Found!!")

#Update the order information
class purchases:
def new_ord(self):
book_id = int(input("Enter the book Id : "))
sup_id = int(input("Enter Supplier Id : "))
qty = int(input("Enter the Quantity : "))
eta = int(input("Estimated expected Delivery (in days) : "))
query = f"INSERT INTO purchases (book_id, sup_id, qty, dt_ord, eta) VALUES ({book_id}, {sup_id}, {qty}, CURDATE(), DATE_ADD(CURDATE(), INTERVAL {eta} DAY))"
cursor.execute(query)
conn.commit()
print("New order Added!!")


def mark_reciv(self):
ord_id = int(input("Enter the order id for order recieved : "))
query = f"UPDATE purchases SET recieved = 'T' WHERE ord_id = {ord_id}"
cursor.execute(query)
conn.commit()
print("Recieved Marked successfully")

def mar_cancel(self):
ord_id = int(input("Enter the order id for order cancelled : "))
query = f"UPDATE purchases SET recieved = 'C' WHERE ord_id = {ord_id}"
cursor.execute(query)
conn.commit()
print("Cancelled Marked successfully")

def view(self):
c = int(input("Select an Option\n1. View orders not Recieved\n2. View orders Cancelled\n3. View orders Recieved\nEnter Your choice : "))
if c == 1:
received = 'F'
elif c == 2:
received = 'C'
elif c == 3:
received = 'T'
else:
return
query = f"SELECT * FROM purchases WHERE recieved = '{received}'"
cursor.execute(query)
results = cursor.fetchall()
if results:
if c == 1:
print("Orders not recieved are")
elif c == 2:
print("Orders Cancelled are")
elif c == 3:
print("Orders recieved are")
for result in results:
ord_id, book_id, sup_id, qty, dt_ord, eta = result
print()
print(f"Order Id: {ord_id}")
print(f"Book Id: {book_id}")
print(f"Supplier Id: {sup_id}")
print(f"Quantity: {qty}")
print(f"Date Ordered: {dt_ord}")
print(f"Estimated Delivery date: {eta}")
print()
else:
print("No orders found.")

class employees:
def add_emp(self):
id = int(input("Enter Your Id for verification : "))
query = f"SELECT mgr_stat FROM employees WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
mgr_status = result[0]
if mgr_status == "T":
print("You Do Not have Manager Rights!!!")
return
else:
print("Employee Not Found!!")
return
name = input("Enter The name of the employee : ")
addr_line1 = input("Enter the Address (line 1) : ")
addr_line2 = input("Enter the Address (line 2) : ")
addr_city = input("Enter the city : ")
addr_state = input("Enter the state : ")
phn = int(input("Enter phone no. : "))
salary = int(input("Enter the salary : "))
query = f"INSERT INTO employees (name, addr1, addr2, addr_city, addr_stat, phone_no, doj, salary) VALUES ('{name}', '{addr_line1}', '{addr_line2}', '{addr_city}', '{addr_state}', {phn}, CURDATE(), {salary})"
cursor.execute(query)
conn.commit()
print("Employee Added Succesfully!")

def assign_mgr_stat(self):
id = int(input("Enter Your Id for verification : "))
query = f"SELECT mgr_stat FROM employees WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
mgr_status = result[0]
if mgr_status == "T":
print("You Do Not have Manager Rights!!!")
return
else:
print("Employee Not Found!!")
return
id = int(input("Enter the employee id to grant Manager status : "))
query = f"UPDATE employees SET mgr_stat = 'T' WHERE id = {id}"
cursor.execute(query)
conn.commit()
print("Manager Status granted")

def search_emp(self):
id = int(input("Enter the id for searching an employee : "))
query = f"SELECT * FROM employees WHERE id = {id}"
cursor.execute(query)
result = cursor.fetchone()
if result:
id, name, addr_line1, addr_line2, addr_city, addr_state, phn, date_of_joining, salary = result
print("Employees Details")
print(f"Name: {name}")
print("Address:")
print(addr_line1)
print(addr_line2)
print(addr_city)
print(f"State: {addr_state}")
print(f"Contact no.: {phn}")
print(f"Date of Joining: {date_of_joining}")
print(f"Salary: {salary}")
else:
print("No Employee Found!!")

def display(self):
query = "SELECT * FROM employees"
cursor.execute(query)
results = cursor.fetchall()
if results:
i = 0
for result in results:
i += 1
id, name, addr_line1, addr_line2, addr_city, addr_state, phn, date_of_joining, salary = result
print(f"Employees Details of Emp no.{i}")
pr

Files changed (1) hide show
  1. README.md +1 -0
README.md CHANGED
@@ -3,3 +3,4 @@ license: "creativeml-openrail-m"
3
  ---
4
  This repository is for backuping Zeipher F222.
5
  I downloaded the model last month via torrent.
 
 
3
  ---
4
  This repository is for backuping Zeipher F222.
5
  I downloaded the model last month via torrent.
6
+