def insert(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO product VALUES (%s,%s,%s,%s,%s,%s,%s);" cursor.execute(sql,(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail)) connection.commit() print('insert') finally: connection.close()
def update(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail,old_product_code): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "UPDATE product SET product_code = %s, product_name = %s, product_category = %s, product_image = %s, product_brand = %s, product_price = %s, product_detail = %s WHERE product_code = %s" cursor.execute(sql,(product_code,product_name,product_category,product_image,product_brand,product_price,product_detail,old_product_code)) connection.commit() print('update') finally: connection.close()
def insert(bill_code,product_code,product_quantity,into_money): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO bill_detail VALUES (%s,%s,%s,%s);" cursor.execute(sql,(bill_code,product_code,product_quantity,into_money)) connection.commit() print('insert') finally: connection.close()
def update(bill_code,product_code,product_quantity,into_money,old_bill_code,old_product_code): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "UPDATE bill_detail SET bill_code = %s, product_code = %s, product_quantity = %s, into_money = %s WHERE bill_code = %s AND product_code = %s" cursor.execute(sql,(bill_code,product_code,product_quantity,into_money,old_bill_code,old_product_code)) connection.commit() print('update') finally: connection.close()
def select_all(): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "SELECT * FROM product " row = cursor.execute(sql) print("select all") finally: connection.close() return [cursor.fetchall(), row]
def delete(product_code): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "DELETE FROM product where product_code = %s" cursor.execute(sql, (product_code)) connection.commit() print('delete') finally: connection.close()
def insert(product_code, inventory_number): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO warehouse VALUES (%s,%s);" cursor.execute(sql, (product_code, inventory_number)) connection.commit() print('insert') finally: connection.close()
def select(bill_code,product_code): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "SELECT * FROM bill_detail WHERE bill_code = %s AND product_code = %s" row = cursor.execute(sql,(bill_code,product_code)) print ("select") finally: connection.close() return [cursor.fetchall(), row]
def insert(customer_code,customer_name,customer_address,customer_phone,customer_sex,customer_DOB,customer_DOP): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO customer VALUES (%s,%s,%s,%s,%s,%s,%s);" cursor.execute(sql,(customer_code,customer_name,customer_address,customer_phone,customer_sex,customer_DOB,customer_DOP)) connection.commit() print('insert') finally: connection.close()
def select(customer_code): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "SELECT * FROM customer WHERE customer_code = %s" row = cursor.execute(sql, (customer_code)) print("select") finally: connection.close() return [cursor.fetchall(), row]
def select_all(): connection = connection_config.get_connection() print ("connect successful!!") try: with connection.cursor() as cursor: sql = "SELECT * FROM product " cursor.execute(sql) cursor_2 = cursor print ("select") finally: connection.close() return cursor_2
def update(product_code, inventory_number, old_product_code): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "UPDATE warehouse SET product_code = %s, inventory_number = %s WHERE product_code = %s" cursor.execute(sql, (product_code, inventory_number, old_product_code)) connection.commit() print('update') finally: connection.close()
def insert(employee_code, employee_name, employee_sex, employee_address, employee_phone, employee_DOB, employee_FWD, employee_salary): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO employee VALUES (%s,%s,%s,%s,%s,%s,%s,%s);" cursor.execute( sql, (employee_code, employee_name, employee_sex, employee_address, employee_phone, employee_DOB, employee_FWD, employee_salary)) connection.commit() print('insert') finally: connection.close()
def update(bill_code, employee_code, bill_date, bill_time, customer_code, total_cost, discount, bill_cost, bill_note, old_bill_code): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "UPDATE bill SET bill_code = %s, employee_code = %s, bill_date = %s, bill_time = %s, customer_code = %s, total_cost = %s, discount = %s, bill_cost = %s, bill_note = %s WHERE bill_code = %s" cursor.execute( sql, (bill_code, employee_code, bill_date, bill_time, customer_code, total_cost, discount, bill_cost, bill_note, old_bill_code)) connection.commit() print('update') finally: connection.close()
def insert(bill_code, employee_code, bill_date, bill_time, customer_code, total_cost, discount, bill_cost, bill_note): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "INSERT INTO bill VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s);" cursor.execute( sql, (bill_code, employee_code, bill_date, bill_time, customer_code, total_cost, discount, bill_cost, bill_note)) connection.commit() print('insert') finally: connection.close()
def update(customer_code, customer_name, customer_address, customer_phone, customer_sex, customer_DOB, customer_DOP, old_customer_code): connection = connection_config.get_connection() print("connect successful!!") try: with connection.cursor() as cursor: sql = "UPDATE customer SET customer_code = %s, customer_name = %s, customer_address = %s, customer_phone = %s, customer_sex = %s, customer_DOB = %s, customer_DOP = %s WHERE customer_code = %s" cursor.execute(sql, (customer_code, customer_name, customer_address, customer_phone, customer_sex, customer_DOB, customer_DOP, old_customer_code)) connection.commit() print('update') finally: connection.close()