def get_product(): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("SELECT * FROM Product") records = cursor.fetchall() return records except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def get_single_service(sid): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("SELECT * FROM Service WHERE serviceid = ?", (sid, )) record = cursor.fetchall() return record[0] except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def add_order(data): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("INSERT INTO Orderinfo (customerid, productid, serviceid, origindate, finalperiod, finalprice) VALUES (?, ?, ?, ?, ?, ?)", data) conn.commit() return True except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def get_order(custid): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("SELECT * FROM Orderinfo Where customerid = ?", (custid,)) records = cursor.fetchall() return records except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def add_user(data): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("INSERT INTO Customer (username, password) VALUES (?, ?)", data) conn.commit() return True except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def update_support(usage, support_id): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute("Update Support SET usage = ? where supportid = ? ", ( usage, support_id, )) conn.commit() return True except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")
def read_service(pid, sid): try: conn = connection.establish_connection() cursor = conn.cursor() cursor.execute( "SELECT * FROM Support WHERE productid = ? AND serviceid = ?", ( pid, sid, )) records = cursor.fetchall() return records except Exception as err: if conn: print("Connection Failed!", err) finally: # closing database connection. if conn: cursor.close() conn.close() print("Connection Closed!")